Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 1.5 KB

File metadata and controls

79 lines (56 loc) · 1.5 KB

JavaScript

Declaring Variables

    var y = "Java";
    const x = "Script";
    let z = "Notes";

Arrays

Declaring arrays

    var arr_1 = ["Johns",1];

Arrays has push and pop function as well For in the above example

arr_1.push("Smith");

This will add "Smith" to the end of the array

var Last_element = arr_1.pop();

This will remove the last element in the array Pop function returns the removed element to the last_element variable

var First_element = arr_1.shift();

This will remove the first element of the array arr_1 and returns it to the First_element variable

arr_1.unshift("happy");

.unshift function adds the variable given as the parameter to the starting of the array as another element.

Functions in JavaScript

example of a normal funciton

function console_debug(){
    console.log("Inside the console_debug");
}
function console_debug_parameterised(a,b){
    console.log(a-b);
}

JS Objects

var obj = { "name : }

Miscellenious

  • console.log("Hello_world") -> is used to debug on runtime as it sends this message to the browser

  • var output = "";
    output +="hello";
    var a=15;
    output +=a;
    //This prints hello15
  • Scope of variables , return keywords etc i.e the basics of oops apply here.

  • Learn more about baiscs like datatype conversion, hoisting and how javascript runs async functions even though it runs on a single thread.