What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-02-19 20:55:09
10.6.1. Function Scope
/*This function takes a string and returns the result of removing all hyphens, -, from the string*/ function removeHyphens(str) { let strWithoutHyphens = '' for (let i = 0; i < str.length; i++) { if (str[i] !== '-') { strWithout... Add solution -
Javascript 2022-02-02 20:05:41
var and let in javascript
// var has function scope. // let has block scope. function func(){ if(true){ var A = 1; let B = 2; } A++; // 2 --> ok, inside function scope B++; // B is not defined --> not ok, outside of block scope return A + B; // NaN --> ... Add solution -
Javascript 2022-01-26 00:30:16
js hoisting
/*Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope (script or function). Be carefull that only declaration gets hoisted NOT the initialitations*/ var x = 5; alert("x is = "+x+". y is = ... Add solution -
Javascript 2022-01-24 23:10:28
Unhandled rejection TypeError: Article.findById is not a function sequelize
/* With Sequelize v5, findById() was replaced by findByPk(). Replace findById using findByPk and everything should work fine. */ // ex: search for known ids Project.findByPk(123).then(project => { // project will be an instance of Project and store... Add solution -
Javascript 2022-01-22 01:50:36
strict mode in javascript
/* even though x is not defined with a keyword like var, let or const, the browser won't throw an error */ x = 1; function myFunc() { "use strict"; /* this will throw an error as y is being assigned a value without it being declared... Add solution -
Javascript 2022-01-21 23:31:16
object destructuring
//simple example with object------------------------------ let obj = {name: 'Max', age: 22, address: 'Delhi'}; const {name, age} = obj; console.log(name); //expected output: "Max" console.log(age); //expected output: 22 console.log(address); ... Add solution