Skip to content

ioncreature/js-interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

  1. ES5 features

    • Explain array methods(map, filter, some, every, reduce, reduceRight, forEach)

      What does this code do?

      emailsString.split( /[,;\s]+/ ).every( email => isEmail(email) );

      Rewrite it with .some() method

    • Object methods

      • Describe property attributes and Object.defineProperty, Object.getOwnPropertyDescriptor methods

        Write method join:

        var a = {a: 1, b: 2, c: 3};
        a.join() // output: a,b,c
        // possible solution:
        Object.defineProperty( Object.prototype, 'join', {
            value(){
                return Object.keys( this ).join( ',' );
            },
            enumerable: false
        });
      • Explain difference between Object.keys and Object.getOwnPropertyNames:

        var a = {q: 1};
        Object.defineProperty( a, 'xxx', {value: 'yyy', enumerable: false} );
        Object.keys(a); // what it returns? 
        Object.getOwnPropertyNames(a); // what it returns? 
      • Setters and Getters

    • Strict mode restrictions

      • Global scope restrictions
      (function(){
          "use strict";
          x = 100;
      })();
  2. Closures

  3. Context

  4. Scope

    • What is the result of:
    Object.prototype.x = 10;
    var y = 20;
    (function(){
        console.log( x, y );
    })();
  5. Write function "reverse" for objects (have to work as for arrays)

    // possible solution
    function reverse( obj ){
        return Object.keys( obj ).reverse().reduce( (res, i) => {
            res[i] = obj[i];
            return res;
        }, {} );
    }
  6. Write function "pop" for objects (have to work as for arrays)

    // possible solution
    function pop( obj ){
        var keys = Object.keys( obj );
        if ( !keys.length )
            return;
        
        var key = keys[keys.length - 1],
        val = obj[key];
        
        delete obj[key];
        return val;
    }

About

Questions for interview for JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published