javascript init an array to 0
new Array(len).fill(0);
Here is what the above code is Doing:
1. We create a new array of length len.
2. We fill the array with 0s.
3. We return the array.
new Array(len).fill(0);
Here is what the above code is Doing:
1. We create a new array of length len.
2. We fill the array with 0s.
3. We return the array.
var regex = /\d+/g; var string = “Any string you want!”; var matches = string.match(regex); // creates array from matches if (matches){ // There is a digit in the string. } else { // No Digits found in the string. } Here is what the above code is Doing: 1. Create a regular expression that…
passport.serializeUser(function(user, done) { done(null, user.id); }); passport.deserializeUser(function(id, done) { User.findById(id, function(err, user) { done(err, user); }); }); Here is what the above code is Doing: 1. We are importing the passport module and the local strategy module. 2. We are importing the User model. 3. We are creating a new local strategy using the local…
const express = require(‘express’); app.use(express.urlencoded({ extended: true })); app.post(‘/api/’, function(req, res) { console.log( req.body.usernameFormInput ); console.log( req.body.emailFormInput ); … }); Here is what the above code is Doing: 1. We’re importing the express module and saving it to a variable called express. 2. We’re using the express module to create a new app. 3. We’re…
var testvar={}; testvar[1]=2; testvar[2]=3; alert(testvar.length); Here is what the above code is Doing: 1. Create an object called testvar. 2. Add a property to testvar called 1, and set it to 2. 3. Add a property to testvar called 2, and set it to 3. 4. Alert the length of testvar. What do you think…
Angular architecture is defined in main three layers is Core layer, Abstraction layer, and Presentation layer. This is also called High-Level Architecture. … Presentation layer also responsible for Unidirectional data flow. Unidirectional data flow — In angular, we have a concept of the hierarchical tree structure Here is what the above code is Doing: 1….
const cb = document.getElementById(‘accept’); console.log(cb.checked); Here is what the above code is Doing: 1. We’re getting the checkbox element by its id. 2. We’re logging the value of the checkbox to the console. The value of the checkbox is either true or false. If the checkbox is checked, the value is true. If the checkbox…