Day 6 - JavaScript Fundamentals

15 January, 2024

33

33

0

  • Day 6 - JavaScript Fundamentals
    • Add JavaScript to html
      • Similar to adding external css to a html page, we can add using <script src="script.js"> element to add external js to the html page.
      • or writing all the javascript code with in the opening & closing tags of <script>
      • To add external css we use <link> element within the <head> element in html where as the <script> is added to the <body> element since only metadata stays in the <head> of the html file.
    • 8 Data types in JavaScript - mdn docs, javascript.info link
      • Number
      • BigInt
      • String
      • Boolean
      • null
        • In JavaScript, null is not a “reference to a non-existing object” or a “null pointer” like in some other languages.
        • It’s just a special value which represents “nothing”, “empty” or “value unknown”.
      • undefined
      • Symbol
      • Object
      • Object is the only reference type and the rest are considered primitive data types.
    • All operators in JavaScript including the assignment operator (=) returns a value 🙂.
      • Example
        let a = 1;
        let b = 2;

        let c = 3 - (a = b + 1);

        alert( a ); // 3
        alert( c ); // 0
    • Escape characters - https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Strings#including_quotes_in_strings:~:text=Escaping characters means
      • For the single or double quotes to be considered within another string we use a \\ right before those quotes or other special characters - This is to escape that character.
        const bigmouth = 'I\\'ve got no right to take my place…';
        console.log(bigmouth);
        // output: I've got no right to take my place…
    • + is also used for concatenating the strings
      • since + is a binary operator & javascript goes from left to right for evaluating, it converts it to string if a either of the operand is a string else converts to num
      • Example
        console.log(1 + "2" + 3);

        // output: 123

        console.log(2 + 3 + "8");

        // output: 58
    • All non-numbers are tried to be converted to numbers when arithmetic operations are done in js, with some exceptions to +
      • Example
        console.log(2 + 3 - "8");

        // output: -3
    • Declaration in js returns undefined
      • let a; → returns undefined
      • Also when a declaration combined with assignment would also return undefined
    • undefined and null have a weird relation
      • the non-strict comparison (==) returns true
      • and the strict comparison (===) since checks the type returns false
      • null is never equal to anything except as mentioned above

33

33

0

Keshav K

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.