JS-07— JavaScript for Programmers, Chapter4to6, Summary, Part3

[11]. Input taken from user using window prompt gets stored as string
To convert that string into integer, we can use, parseInt() function.

var num_var = parseInt (str_var)

[12]. In JavaScript, we need not declare the data type of variables to be used.
i.e. A variable in JavaScript, can contain any data type.
Just like C, we can give value to a variable while declaration and can also initiate multiple variables using commas
for e.g.
var num = 23 ;
var str = “wow” ;
var var1, var2, var3 ;

[13]. If-else conditional statement is just like C

[14]. Associativity of most operators is left to right, except assignment operator (= += -= *= /= and %= ). [Exactly like C. So, pre-increment (++x), ternary operator (? :) follows R to L order, just like C.]

[15]. Increment or Decrement operator can only be applied to lvalue expressions (left-hand-side expression i.e. A variable or expression that can appear on the left side of an assignment operation.)
For e.g.

x+1 = x+2 ; // this is not valid
++(x+1) // therefore, it will be not valid.
(x+1)++ // and neither this will be valid

[16]. Do not add spaces between <= or >=

> = //wrong
>= //correct

[17]. Units for font sizes:

px = static measurement (1px = 1/96th of an inch)
pt = static measurement (1pt = 1/72nd of an inch)(So, 16px = 12pt)
ex = relative measurement wrt size of letter ‘x’
Example, in p tag, size of x is suppose 16pixels, than 1.5ex will represent 24pixels

[18]. Like in C, we can define counter variable inside Condition Bracket of If statement.

[19]. As in C, even if we dont initialise or implement condition or mark increment/dec… even then, we have to put two semi colons inside for’s brackets.

for (int i; ; )
/* this is working loop, where
initial variable gets the value 0,
loops till infinity,
and increment should set to 1
(although in my checking, the increment didnt set itself to 1. It was 0. i.e. no increment just 000...)*/

[19]. In a while or for loop, since the incrementing or decrementing takes place at the end, so it doesn’t depend much whether we use post or pre.

— -

Thank you.

Summary of Book : JavaScript for Programmers
Authors: P.J. Deitel and H.M. Deitel
Publisher: Pearson

--

--

--

Content Writer | IT Student

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Raman Kumar

Raman Kumar

Content Writer | IT Student

More from Medium

JS-09 — JavaScript for Programmers, Chapter7

Best JavaScript Frameworks to learn in 2022

Two try-catch caused dive deep into JavaScript asynchronous programming

Write beautiful and Elegant Javascript code with short-circuit evaluation.