learning-zone / javascript-basics Goto Github PK
View Code? Open in Web Editor NEWJavaScript Basics
Home Page: https://learning-zone.github.io/javascript-basics/
JavaScript Basics
Home Page: https://learning-zone.github.io/javascript-basics/
is there a way to generate anki / quizlet flashcards from these interview questions ? Could be useful for everyone who wants to use spaced repetition system.
Code below:
Q. How do you create an object with prototype?
const user = {
name: 'John',
printInfo: function () {
console.log(`My name is ${this.name}.`);
}
};
const admin = Object.create(person);
admin.name = "Nick"; // Remember that "name" is a property set on "admin" but not on "user" object
admin.printInfo(); // My name is Nick
Object.create(user) instead Object.create(person)
Q. What is the precedence order between local and global variables?
Current:
var msg = "Good morning";
function greeting() {
msg = "Good Evening";
console.log(msg);
}
greeting();
Maybe missed "var" in inner variable:
var msg = "Good morning";
function greeting() {
var msg = "Good Evening";
console.log(msg);
}
greeting();
Object Destructuring:
const { i = 2, j = 4, k = 6 } = { n: 10 };
console.log("i: " + i); // 10 -> should be 2
console.log("j: " + j); // 4
console.log("k: " + k); // 6
fd275d5#diff-5fbfdce5c2abc62be0d0053fc1639ecf9ed0ec06fafdd8cca32410f2c8f9d1ca
The problems folder was removed in this commit, was this intentional?
On this page: https://github.com/learning-zone/javascript-interview-questions
We have a section called "Q. What is the purpose of exec method?" with code below:
var pattern = /you/;
console.log(pattern.test("How are you?")); //you
Is it "exec" instead "test" ?
var pattern = /you/;
console.log(pattern.exec("How are you?")); // ["you", index: 8, input: "How are you?", groups: undefined]
Q. What is the purpose of seal method?
We have:
const object = {
property: 'Welcome JS world'
};
Object.freeze(object);
object.property = 'Welcome to object world';
console.log(Object.isFrozen(object)); // Welcome to object world
delete object.property; // You cannot delete when sealed
console.log(object.property); //Welcome to object world
Maybe:
const object = {
property: 'Welcome JS world'
};
Object.seal(object);
object.property = 'Welcome to object world';
console.log(Object.isSealed(object)); // true
delete object.property; // You cannot delete when sealed
console.log(object.property); //Welcome to object world
The question is not listed in question list What is the object type
Its between 43. and 44. question
It that question the comments/object is not good, wrong firstName and lastName (object or comments needs to be fixed)
On website, when first option in the table is clicked What is difference between document.getElementById() and document.querySelector()?
, user is not redirected to the QnA section beneath the table.
The reason is a mismatch in ids.
The table entry link:
<a href="#q-what-is-difference-between-document-getelementbyid-and-document-queryselector">What is difference between document.getElementById() and document.querySelector()?</a>
QnA section header:
<h2 id="q-what-is-difference-between-documentgetelementbyid-and-documentqueryselector">Q. <strong><em>What is difference between document.getElementById() and document.querySelector()?</em></strong></h2>
h2 tag id is missing a few hyphens
Q. What are the conventions to be followed for the usage of swtich case?
maybe:
Q. What are the conventions to be followed for the usage of switch case?
Your answer is:
Global variables are those that are available throughout the length of the code without any scope. The var keyword is used to declare a local variable but if you omit it then it will become a global variable
msg = "Hello" // var is missing, it becomes global variable
The problem with global variables is the conflict of variable names of local and global scope. It is also difficult to debug and test the code that relies on global variables.
But I think that:
Global variables are those that are available throughout the length of the code without any scope. The var keyword is used to declare declares a function-scoped or globally-scoped variable but if you omit it then it will become a global variable only.
msg = "Hello" // var is missing, it becomes a global variable
But var in the 'Block scope' is still a global variable:
var x = 1;
if (x === 1) {
var x = 2;
console.log(x);
// expected output: 2
}
console.log(x);
// expected output: 2
Your Answer is:
‘var x = 1’ will create a variable within the current scope. Given this is declared in a function, x will not be available outside it unless explicitly returned.
‘x = 1’ will create a variable within the global scope. Thus, any other code can access and alter its value. It is generally a bad practice to use variables in a global scope.
But... I think that this is a wrong answer, Because in MDN :
and
in strict mode: 'x = 1' is not allowed.
So I hope you correct it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.