Category Archives: Javascript

A simple todo app in javascript

Asked in Box onsite interview. With a node.js server on backend. $().ready(function() { $(‘#add’).on(‘click’, addTask); $(‘#tasks’).on(‘click’, markComplete); // Alternative way // var tasksElement = document.getElementById(‘tasks’); // tasksElement.addEventListener(‘click’, markComplete); //document.getElementById(‘task-input’).onkeydown = function(e){ $(‘#task-input’).on(‘keydown’, function(e) { if(e && e.keyCode == 13){ addTask(); … Continue reading

Posted in Javascript | Leave a comment

Simulate a debounce function

http://obscurejavascript.tumblr.com/post/115595038489/debounce-in-javascript var debounce = function(callback, delay) { var timeout = null; return function() { var args = arguments, context = this; clearTimeout(timeout); timeout = setTimeout(function() { callback.apply(context, args); }, delay); }; };

Posted in Javascript | Leave a comment

Debounce and Throttle in Javascript

Throttle: the original function be called at most once per specified period. Example: while window resizing Debounce: the original function be called after the caller stops calling the decorated function after a specified period. Example: Validating contents of a text … Continue reading

Posted in Javascript | Comments Off on Debounce and Throttle in Javascript

Trulia On Site Questions

1) How does Oauth work ? 2) Explain journey of a URL ? 3) How does caching work in a CDN? How do you push a new file out to CDN? 4) Emulate the throttle function() // Allow callback to … Continue reading

Posted in Javascript | Leave a comment

IIFE in Javascript (Immediately Invoked Function Expression)

http://benalman.com/news/2010/11/immediately-invoked-function-expression/

Posted in Javascript | Leave a comment

How to achieve static variable in javascript

2 Ways : 1) Make use of the fact that functions are objects and can have properties (Even using “this” instead of uniqueID inside the function will do) function uniqueID() { // Check to see if the counter has been … Continue reading

Posted in Javascript | Leave a comment

Interview Questions for Javascript

https://github.com/h5bp/Front-end-Developer-Interview-Questions#performance-questions https://www.sitepoint.com/5-typical-javascript-interview-exercises/

Posted in Javascript | Leave a comment

Good Blogs for Javascript

1) http://lucybain.com/blog/ 2) http://adripofjavascript.com/archive.html 3) http://blog.sourcing.io/interview-questions

Posted in Javascript | Leave a comment

Javascript Questions Set3

1) What is event delegation? Event delegation is when you bind an event listener to a parent (or ancestor) element rather than the element(s) you are particularly interested in. When the event is triggered you can check the event target … Continue reading

Posted in Javascript | Leave a comment

Function overloading in Javascript

Unique things about arguments in functions in Javascript: 1) You can pass any number of parameters to a function without causing an error. 2) You can also pass in no arguments but still make use of arguments inside the function … Continue reading

Posted in Javascript | Leave a comment