Code Monkey home page Code Monkey logo

jsrevision's Introduction

JsRevision

Escape sequence in js start with \

  • " for printing double quotes in a string
  • \ for backslash
  • ? For question mark
  • \n new line
  • \t tab
  • \b backspace

String variable cannot be mutated but can be reassigned with new string

Const let var

  • let : block scope variable
  • const : same as let and prevents mutation
  • var : accessible everywhere

const array cannot be reassigned with new string but can be mutated

To completely prevent mutation we use Object.freeze() method

// Const variable should be allcaps
const MYCONST= { pi : 3.14}

Object.freeze(MYCONST)

Anonymous functions or arrow functions

Rest operator for n number of arguments

... Three dots

Var f = Function(...args) { //code} 

All the arguments will now be clubbed into an array.

Spread operator for making a copy

Arr1= ["a" , "b"]
Arr2 = [...arr1]; 

Destructuring assignment

More or less same as unpacking

[a,b] = [b,a] // swapping
const [z,x, , y] = [1,2,3,4,5] // 3 is skipped

Setters and Getters

Setters and getters in js are defined same as functions but are used as properties. There was no ( ) used while calling of these properties.

Setter is used to set the values of properties getter is used to get the values of properties of an object

Definition of setters and getters

Set property_name() {
//Code }

Same with get
Both are Used in a class

Global and execution context

Global context : all about collecting what has been written in the program. has window object in it

Execution context : when program is in execution line by line the execution blocks are stacked over global context. So in js when a function is called before its definition there's no error because global context is already knows about it.

Two things that global context does with functions and variables

Function declarations are scanned and made available. Variable declarations are scanned and made undefined.

One liner arrow functions : Const f = par => { //code } F is used as function name while calling Par is the parameter If multiple parameters are used then syntax is (par1,par2) '

. every ( ) method is used on arrays which return true if something is true for each element of array

Arr.every(iseven) //iseven is a user-defined function. Remember no parenthesis

jsrevision's People

Contributors

pooja-lohar25 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.