Giter VIP home page Giter VIP logo

javascript-basics's People

Contributors

abisekhsubedi avatar adam-books avatar aniruppat avatar anupamit avatar bougwal avatar elideh avatar iamrc1 avatar imkrantiprasad avatar kishor82 avatar learning-zone avatar negiakash890 avatar oscyp avatar pradeepkumar2 avatar talentedandrew avatar vigneshwaran-chandrasekaran avatar vlvagerviwager avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-basics's Issues

Wrong example in Regex Pattern section

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

issues in questions 8 & 297... and its answers

8: What are global variables?

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

297: In JavaScript, What is the difference between var x = 1 and x = 1?

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 :

The var statement declares a function-scoped or globally-scoped variable, optionally initializing it to a value.

and

in strict mode: 'x = 1' is not allowed.

So I hope you correct it.

Because JavaScript has 3 types of scope:

  • Block scope
  • Function scope
  • Global scope

flashcards automation

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.

Website: user not redirected on clicking on 1st link

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

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.