Giter Site home page Giter Site logo

tcorral / javascript-challenges-book Goto Github PK

View Code? Open in Web Editor NEW
808.0 74.0 232.0 3.29 MB

Challenge yourself learning and understanding the most obscure and tricky parts of Javascript. http://tcorral.github.io/javascript-challenges-book/

Home Page: http://jsbooks.revolunet.com/

License: Other

JavaScript 100.00%
javascript javascript-challenges challenge tricky-parts

javascript-challenges-book's Introduction

Javascript Challenges

This book will challenge you to learn and understand the most obscure and tricky parts of Javascript.

In order to perform the best that you can I recommend you not to cheat taking a look at solutions before you suggest one.

This book can be used as a learning resource for Javascript training if you want, but please send a tweet recommending us to other people.

I hope you enjoy this book because this is the purpose of this book.

Feedback is welcome.

Thanks a lot to GITBOOK team for it's amazing project to write your own books using Github repos.

javascript-challenges-book's People

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  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

javascript-challenges-book's Issues

Book title

On gitbook.io, the book title is "Javascript_Challenges" instead of "Javascript Challenges".

Host it on gitbook.io

This book is really good, would you be interested in hosting it using gitbook.io ?

Floats Operations Imprecision- solution

Hi!
Thanks for creating javascript challengers book. I click the solution button to find out the answer, then submit the same answer as solution. It displays "ReferenceError: match_answer_and_solution is not defined". I feel confused.

terminator challenge misleading

I assume you want to make the reader think about preventing XSS but your solution doesn't really point the reader to that...

Make the summary accessible more easily

You said feedback welcome, so here it is:
Wouldn't it be nice to have an overview of the book by seeing the summary right after the Introduction in Readme.md?

objects1 solution is suboptimal

You are destroying the semantics of Object.prototype.hasOwnProperty.
A more elegant solution would be:

Object.defineProperty(obj, "name", {  enumerable: false });

input_search unclear

http://tcorral.github.io/javascript-challenges-book/input_search/README.html
Although the keypress event is deprecated it's unclear to me, why there is a performance issue that keyup would solve. Correct me if I'm wrong, but I think the difference is that when holding down a key on the keyboard, the operating system may repeat the character input if you keep it pressed. keypress would be refired in this case while keyup wouldn't. But that's an issue I would usually overcome with a delay, so that I only send the AJAX request after a certain amount of time passed after a keypress.

A possible performance issue I also see is that the #list element is beeing searched over and over again in the loop. Caching would help here.

My "solution" would be:

function delayTimer(delay){
  var timer;
    return function(fn){
      timer = clearTimeout(timer);
      if(fn)
        timer = setTimeout(function() {
           fn();
        },delay);

      return timer;
  };
}
var delayer = delayTimer(500);

$( document ).ready( function() {
  $( '#inputSearch' ).keyup( function() {
      delayer(function() {
        var $list = $( '#list' );
        $.ajax( {
          url: 'http://www.domain.com/search',
          data: this.value,
          success: function ( data )
          {
              var results = data.results;
              $list.empty();
              $.each( data, function ( item ) {
                  $list.append( '<li>' + item + '</li>' );
              } );

          },
          error: function ( xhr, status, error ) {
              console.log( 'Something goes wrong!', status, error.message );
          }
        } );
      } );
  } );
} );

Challenge 1.4: Checking Properties - my shorter solution

I think the following solution should be added:

  1. It is shorter
  2. use of prototype is not something necessary for that specific question spirit, maybe question should be improved

var key,
obj = {
name: 'john',
surname: 'doe'
};

for (key in obj) {
if (obj.hasOwnProperty(key)) {
if (key != "name") {
console.log(key + ' exists in obj');
console.log(key + ': ' + obj[key]);
continue;
}
else console.log(key + " doesn't exist in obj");
}
}

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.