0% found this document useful (0 votes)
4 views3 pages

Complete Js

The document provides an overview of JavaScript fundamentals, including case sensitivity, mathematical operations, data types, and variable declaration. It explains the importance of using brackets for order of operations, the handling of decimal values, and the differences between 'let', 'const', and 'var' for variable declaration. Additionally, it covers string manipulation, type coercion, and the use of comparison operators.

Uploaded by

piwile2631
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Complete Js

The document provides an overview of JavaScript fundamentals, including case sensitivity, mathematical operations, data types, and variable declaration. It explains the importance of using brackets for order of operations, the handling of decimal values, and the differences between 'let', 'const', and 'var' for variable declaration. Additionally, it covers string manipulation, type coercion, and the use of comparison operators.

Uploaded by

piwile2631
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

JavaScript is case sensitive.

Can do math: Handles decimal and integer values properly


Order of operations in numbers:
Multiplying and division done first(same priority:left to right)
Addition and subtraction are done later(same priority:left to right)
comparision operators
logcal operators
Brackets can be used to control operations, inside bracket operations are done
first.
Brackets must be closed.

Computers can store only 0 and 1


decimal or floats, computer can't store properly
0.25 can be handled properly by computers.

20.95+7.99= 28.939999999998
(2095+799)/100=28.94
Asvised to use cents when calculating money and then convert back dividing by 100.
document.body.innerHTML("Hello") -> removes the content of the site and displays
hello.

Rounding:

Math.round(2.2)
2
Math.round(2.8)
3

((2095+799)*0.1)/100
2.894

Math.round((2095+799)*0.1)/100

cents calculation is rounded then converted by 100

string:
'hello'
can be concatenated
'hello'+'buddy'+ .....
'hellobuddy.....'

typeof gives us datatype

typeof 2
will give
'number'

typeof 'hello'
will give
'string'

'hello'+3
hello3(type coercion)

js adds from left to right

3 ways to create strings


1. ' '
2. " "
'I'm learning js'
here the single inverted comma will end the string early

Here, double quotes is useful

CHaracter can be letter,number and symbols


also escape character is there (start with backslash)
\' creates a ' which is just a string
\n creates new line
\" double quote that is just string.

3.`hello` = template strings


(i) interpolation=insert value directly in the text
'items(${1+1}): $${(2095+799)/100}` (happens by ${add whatever you want
to})
recommended solution

(ii) Multi-line string


`some
text`
some\ntext

onclick(),ondblclick() attribute in html runs javascript code inline


title() attribute in html shows whatever we want to convey while hovering on the
text/button or any element

console.log() redirects code to console from any source file to the console on
website

"let variable_name" creates a variable

$ and _ can be used in variable names


can't start with a number

js follows camelCase

PascalCase(1 usage in js)


kebab-case(html)
snake_case

if the variable value is not changing later on


safer to use 'const' instead of 'let',this makes sure our variable doesn't change
in the code

var can be used in place of let


but it has some issues

=== used to check with keeping typeofdata in mind


but == converts both into same datatype and then checks

!== checks for inequality

typeof can also be used with variables to tell the type of value stored in that
variable.

scopes of a variable exists in the space where it has been created.


"var" keyword doesn't follow scope rules.

You might also like