Skip to content

Instantly share code, notes, and snippets.

@fazliraziq
Last active June 18, 2021 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fazliraziq/4ec3d7f4c22f702500d4e4f76906afdc to your computer and use it in GitHub Desktop.
Save fazliraziq/4ec3d7f4c22f702500d4e4f76906afdc to your computer and use it in GitHub Desktop.
Javascript Snippets
//Regular Expression for validation of MobilePhone Numbers
var str = "+0099812731";
var patt = new RegExp("^[+|0/d]([0-9]{12})$");
var res = patt.test(str);
console.log(res);
'use strict'
//Variables , Contant and Literals
/* ************VARIABLES**************** */
let age = 24; // Variable
console.log(age); //Output - 24
let name , fullname = "Eminem";
console.log('Name : ',name); // Output - Undefined
console.log('Full Name : ',fullname); // Output - Eminem
var value = 23;
console.log('Value :',value); // Output - 23
var temp;
var temp2 = null;
console.log('Temp :',temp); // Output - undefined
console.log('Temp2 :',temp2); // Output - null
//Note : Null and undefined is not equal
const data = "Hello world"; //Variable - Constant : Value can not be changed later
console.log('Data : ',data); // Output - Hello world
//data = "my world"; //Expect an Error
/**********************LITERAL*************** */
let goal = "Aim right"; //Aim right is literal
let height = 20; //20 is literal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment