background preloader

Javascript

Facebook Twitter

Execution context and closures

What are some advanced JavaScript techniques that you don't see often but should? - Quora. 5 Useful JavaScript Libraries. Front-end development is the coolest part of the complete web development process. Ever now & then you get to see new libraries and articles coming out. Basically, the Internet is full of various tools for front-end development. In short, you have got tool for everything. In this post, I am going to share 5 useful JavaScript libraries that can help your front-end development. Moment.js A powerful JavaScript library that lets you manipulate and display dates easily. GitHub – Hello.Js Tired of adding social media login integration to your website?

GitHub – is.js Hate regex and creating validations? GitHub – Underscore.js Underscore provides over 100 functions that can ease your day to day work in JavaScript. GitHub — Awesomplete A simple lightweight, zero dependency JavaScript library for Autocomplete solution. Stay Digified! Sachin Khosla Topics: Why we chose to move to HTML5 video. We recently switched to HTML5 from a Flash-based video player for all Facebook web video surfaces, including videos in News Feed, on Pages, and in the Facebook embedded video player. We are continuing to work together with Adobe to deliver a reliable and secure Flash experience for games on our platform, but have shipped the change for video to all browsers by default.

From development velocity to accessibility features, HTML5 offers a lot of benefits. Moving to HTML5 best enables us to continue to innovate quickly and at scale, given Facebook’s large size and complex needs. Benefits of HTML5 Development velocity Using web technologies allows us to tap into the excellent tooling that exists in browsers, among the open source community, and at Facebook in general. Testability We have an excellent testing infrastructure at Facebook. Accessibility HTML5 made it possible for us to build a player that is fully accessible to screen readers and keyboard input. The challenges we had to overcome. What is the JavaScript Event Loop? Introduction If you’re like me, you love JavaScript. Yea, it’s not the perfect language but seriously, is there even such a thing as a perfect language?!

So despite it’s flaws and all, I love programming on the web and how JavaScript enables me to build applications that connect with the world. But JavaScript is deep — it’s got a complex interior that takes a while to really understand. One of these deeper aspects of JavaScript is it’s Event Loop. It’s possible to program in JavaScript for years and not really understand exactly how the event loop works in JavaScript.

JavaScript in the Browser When we think of JavaScript, we commonly think of it in the context of a web browser — this makes sense since most of us code our JavaScript for the client-side. Before diving into the event loop, we need a basic understanding of the JavaScript Engine and what it does. JavaScript Engine So how does the JavaScript engine know how to process a single line of JavaScript at a time? Let’s see an example! Beginner's Tutorial to WebRTC using PeerJS. WebRTC is a technology that enables real-time communication between web browsers.

It is relatively new, and the API definition is still considered to be a draft. Coupled with the fact that WebRTC is not supported by all major web browsers yet, (and among the ones that do, some of them do not support every feature of this technology), this makes it relatively difficult to use WebRTC for any mission critical applications.

Or so you would think! Connect Four over WebRTC using PeerJS: Look ma, no server! Since it was first introduced by Google in May 2011, WebRTC has been used in many modern web applications. In this article, we will take a look at how WebRTC can be used to make a simple P2P web game of Connect Four. Data over WebRTC Before we start, it is important to understand that WebRTC is not all about transmitting audio and video streams. WebRTC infrastructure - an ocean of acronyms Meet PeerJS With PeerJS, identifying peers is even simpler. Connect Four Goes P2P PeerJS Server Game Logic. PeerJS - Simple peer-to-peer with WebRTC. Jspm.io - Frictionless Browser Package Management.

Moment.js | Home. JavaScript Architecture for the 23rd Century - Modern Web. Jonathan discusses JavaScript architecture patterns of the 23rd century and what the future of JavaScript holds for the 24th century.” JavaScript applications have grown in size and complexity for the last several years. More and more single page applications have hit the market, and demands for that type of experience have increased to the point where even Google finally decided to render JavaScript when it crawls pages. This demand for SPA type applications has made JavaScript architecture increasingly important.

JavaScript, being a dynamic language, you have to go the extra mile to ensure that the code is written in a maintainable fashion and to avoid spaghetti code. For a long time it seemed like it was ok to just use a single file full of jQuery selectors and event handlers. An architectural pattern is not something that you sit down and write. Constructor function Starship() {} Every function you declare in JavaScript can be used as a constructor to create an instance. If (! Enter AMD. Build Wars: Gulp vs Grunt. Gulp vs Grunt A brief history of Grunt I realized that a task-based build tool with built-in, commonly used tasks was the approach that would work best for me Ben AlmanMarch 2012 Single, global Grunt: $ npm install -g grunt Configuration over code Built-in init task to get you started $ grunt init jquery Kitchen sink init concat lint min qunit server test watch Simple config Common build steps Designed for small libraries & plugins What was wrong?

Global 'grunt' command... Grunt v0.4 Released Feb 2013 grunt.js became Gruntfile.js 'init' task became 'grunt-init', inspired Yeoman Local Grunt install for each project Global 'grunt' command runs local Grunt Everything is a plugin, no built-in tasks Stream-based build system Code over configuration Small, idiomatic Node modules Really simple, elegant API Basic Gulpfile var gulp = require('gulp'), stylus = require('gulp-stylus'), autoprefixer = require('gulp-autoprefixer'); Gulp tasks run from terminal $ gulp taskname Streaming Builds @maxogden It's not too hard. What's the difference between function.call and function.apply? Today I read a great blog post by Mark Needham titled JavaScript: Confusing ‘call’ and ‘apply’.

A while back I wrote an article for our Tech Times newsletter about the JavaScript arguments object. It was called arguments: A JavaScript Oddity because it has all sorts of interesting behaviors that are useful to know about. I realized that although I’d used both call and apply in that article I hadn’t talked about the difference. Well it’s actually quite simple. First of all, both methods expect a thisArg as the first argument. This is the argument that gives the function a context; it determines the value of the JavaScript keyword this inside the function that is called or applied. The single difference is that the call method requires that arguments are specified separately; the apply method takes them as an array. Function.call(thisArg[, argument1[, argument2[, function.apply(thisArg[, argumentArray]); Hope that’s useful to you!

Feature image by Sudhamshu. 5 Typical JavaScript Interview Exercises. JavaScript developers are in high demand in the IT world. If this is the role that best expresses your knowledge, you have a lot of opportunities to change the company you work for and increase your salary. But before you are hired by a company, you have to demonstrate your skills in order to pass the interview process. In this article I’ll show you 5 typical questions asked for a front end job to test the JavaScript skills of the candidate and their relative solutions.

It’ll be fun! Question 1: Scope Consider the following code: What will be printed on the console? Answer The code above prints 5. The trick of this question is that in the IIFE there are two assignments but the variable a is declared using the keyword var. The other trick of this question is that it doesn’t use strict mode ('use strict';) inside the function. Question 2: Create “native” methods Define a repeatify function on the String object. Should print hellohellohello. A possible implementation is shown below: Conclusion. 15 Best Node.js Frameworks For Developers - Webdesigncone. Node.js frameworks are useful javascript frameworks which can help you develop web applications. It has lot of features to develop web applications. Node.js is a javasript platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.

Node. js frameworks are the most useful when it comes to web application development and also it speed up your web development process. Node.js consists of different kind of frameworks such as MVC framework, REST API and generators, full-stack framework, lots of libraries as server library that making it possible to sun a web server without the use of external software such as Apache. Node.js frameworks internally uses the Google V8 JavaScript engine to execute code, and a huge percentage of the basic modules are written in JavaScript. You may also like this : 15 Best Responsive HTML5 Frameworks 2014 Best Node.js Frameworks For Web Developers Kiss Kiss.js uses Django-like templates from swig. Sails Total Partial Flatiron Opa. 20 Fresh JavaScript Tools for Developers - Code Geekz.

JavaScript serves a multitude of ways by which to create interactive websites, web applications. Utilizing JavaScript into your web projects can enable you to move HTML elements around, create a variety of custom animations, and give your visitors a better end user experience. We are back with another JavaScript Tools roundup released recently, following tools are capable of serving you for number of tasks and help you to optimize and create innovative web applications quickly and easily. We hope you will find the list useful for your development needs, please send us your feedback by posting a comment below. Enjoy !! 1. MotorCortex.js MotorCortex makes web animations easy, providing the ability to describe them through CSS-like syntax and stop messing animation logic with your actual javascript code. 2.

JS Nice makes even obfuscated JavaScript code readable. 3. Ouibounce is a small library enabling you to display a modal before a user leaves your website. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Function Declarations vs. Function Expressions. Lets start with a short quiz. What is alerted in each case? : Question 1: Question 2: Question 3: Question 4: If you didn’t answer 8, 3, 3 and [Type Error: bar is not a function] respectively, read on… (actually read on anyway ;-) ) What is a Function Declaration? A Function Declaration defines a named function variable without requiring variable assignment. E.g. ECMA 5 (13.0) defines the syntax asfunction Identifier ( FormalParameterListopt ) { FunctionBody } The function name is visible within it’s scope and the scope of it’s parent (which is good because otherwise it would be unreachable) What is a Function Expression? A Function Expression defines a function as a part of a larger expression syntax (typically a variable assignment ).

ECMA 5 (13.0) defines the syntax asfunction Identifieropt ( FormalParameterListopt ) { FunctionBody } (though this feels incomplete since it omits the requirement that the containing syntax be an expression and not start with “function”) Wait, what’s Hoisting?

Visualizations

20 Best JavaScript Resources for Web Designers and Developers. Javascript is a very widely used computer programming language, generally having the implemented use in web browsers, and is basically used to integrate client-side scripts for the user to interact with the server. It is also very widely used on the server side for the process of game development, mobile applications, some wide server applications, etc. This is a prototype based programming language with first class function and class libraries. Javascript was first ever introduced by the Netscape corporation, and further adopted by the java corporation, to be forming this great and resourceful web development platform. There are a lot of authoring tools, resources, etc, are available throughout to be implemented to use. Considering the great variety, some of the tools are free or cost, some are paid, and carry their particular features respectively. Today we have collect great javascript resources for designers and developers for easily download online. 1) gif.js 2) togetherjs 5) chartjs.

Bower

Numeral.js. Sails.js | Realtime MVC Framework for Node.js. Toastr by CodeSeven. Socket.IO: the cross-browser WebSocket for realtime apps. Lexical environment and function scope. Underscore: LINQ (almost) for JavaScript. As part of my emerging series on LINQ from Scratch, I’d like to take a small detour today into what you do if you need the functionality of LINQ in your JavaScript program. One answer is the underscore.js library. Here’s what they say about themselves: I just wanted to do a query against some data in memory, and underscore was the perfect answer. The data I had consisted of a series of books and I wanted to filter out all but the best in each genre, to use with KendoUI. As you can see, the data consisted of a small set of books, each with a rating. . _.sortBy was passed my entire data set, and sorted based on the book’s rating.

. _.groupBy was passed that reverse-sorted collection to group by the genre. What I got back from _.map was an array of arrays so I called _.flatten to turn that into a single dimension array. There is much more you can do, but you can see very quickly that much of the functionality you would get from LINQ is available to JavaScript programmers through this library. Writing an Awesome Build Script with Grunt. Grunt is a fantastic build system for web development, but it can be tricky to set up. In this guide, you’ll learn to configure Grunt to build a modern web project. When you’re done, your Gruntfile will be able to: Copy files from a source directory to a build directory Remove build filesCompile Stylus files and add vendor prefixes to themCompile CoffeeScriptMinify CSS and JavaScriptCompile JadeAutomatically build source files when they’re modifiedRun a development server Getting started If you haven’t already done so, install Node.js and NPM.

Create a package.json with the content below. This file defines your project as an NPM package and declares your project’s dependencies. Copy A good build script always keeps the source code separate from the build files. To get started, you’ll make Grunt copy the files from a source directory to a build directory. Let’s break this down. Inside the Grunt configuration, you’ve added the configuration for a copy task. Clean Build Stylus The ! Autoprefixer. Everything you wanted to know about JavaScript scope. 10 Essential JavaScript Tools Developers Must know About. As the many web developers have already started working together to develop some real piece of softwares or applications which provide the flexibility to the newbies in many ways like it becomes much easier to find mistakes from their written code & the most important factor is that they can create well optimized code for developing some great web pages.

For development tools or applications, one need to think efficiently in many aspects so that they achieve maximum utilization of already written material instead of writing the same code for each and every function. Because writing the same line of code for every function not only increase the size of application, but also becomes difficult to manage and find errors. Now, This trend of utilizing resources becomes more popular day by day and almost every language started following this simple rule.

jQuery

Angular.js. Profiling.