Basic Javascript concepts – vol 1

Comments in Javascript:

There are two ways to comments on Javascript. Single line comment and multiline comment. To start with a single line comment in one line. here is the sample: //This is single-line comment

Multiline comment means you can comment through two to more lines you want. sample is:

/*This is

multiline

comment

*/

Variable in JavaScript:

we can call the variable in three ways. They are var, let , and const

var and const use for reassigning a variable Where const can’t reassignable.

For example :

const name = " John";
var city = "Miami";
let city = " Calfornia"

one more thing to remember the variable name cannot start with numbers. To multi-words variable, there are three ways

  1. Camel case: var firstName = " john";
  2. Underscore: var frist_name = "john";
  3. pascal case: var FirstName = "John";

Data type:

There are two types of data types in Javascript.

  1. Primitive Datatype :
    • The value stored directly in the location variable access.
    • stored on the heap.
    • Example: strings, numbers, boolean, null, undefine, symbols(ES6).
  2. Reference Datatype:
    • access by reference.
    • a pointer to a location in memory
    • an object that is stored on the heap.
    • Example: arrays, objects, functions, dates, etc.

String: Any text which covered with "" is a string in javascript. for example: const name = "John".

Numbers: All numeric are numbers in Javascript. Example: const age: 34;

Booleans: true and false are boolean. sometimes its work as 0 and 1

Array: Array uses to store multiple items in javascript. Example: const fruits = ["apple", "banana", "seed"];

1 Comment

  1. tҺe website іѕ really good, I enjoy it!

Leave a Reply

Your email address will not be published. Required fields are marked *