Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 JAVASCRIPT


  Be cautious before deciding to use ReactJS in your product

ReactJS is an open source JavaScript library used for writing user interfaces. It revamps the way developers write web applications. More and more front end developers start to use this Facebook crafted library in their products or projects nowadays.However, although ReactJS is an open source library under BSD license, it doesn't mean there is no risk to freely adopts it in your products. If you are building or plain to build some products which may compete with Facebook or its subsidiaries, your license for using ReactJS will be revoked immediately. Kind of surprise, right?In fact, ...

3,995 0       JAVASCRIPT FACEBOOK REACTJS VUE


  JavaScript to scroll element into view

In AJAX applications, there are frequent needs to scroll some element into view after some modification to the page. For example, after adding an item or updating an element in an admin panel, the page may need to be scrolled to the item added or updated so that we can see the changes immediately.In these cases, JavaScript can be used to scroll the element we want to show. In Vanilla JavaScript, there is no built-in function which can achieve scroll_element_into_view(), but most of modern browsers provide function like window.scrollTo() which can scroll the page to some position. window.s...

16,167 0       JAVASCRIPT JQUERY SCROLLTO HOW-TO


  JavaScript programming style

Douglas Crockford is a JavaScript expert, he is the inventor of JSON. In November 2011 he made a speech "Youtube", during the speech he talked about what JavaScript programming style is.I recommend this speech to everyone, it not only helps you learn JavaScript but also make you enjoying because Crockford is very humorous and he made audience laugh frequently.Next I will summarize JavaScript programming style according to this speech and his article code convention. The so-called programming style is a set of rules of writing code. Different programmers have different programming styles.Some p...

7,837 0       JAVASCRIPT PROGRAMMING STYLE CURLY BRACES EQUAL


  jQuery to check whether checkbox is checked

In Vanilla JavaScript, the correct way of checking whether a checkbox is checked is to get the property checked of the checkbox. Assuming there is an checkbox with id "checkbox1", below line will return true if the checkbox is checked while it will return false if the checkbox is unchecked:document.getElementById("checkbox1").checkedIn jQuery, there are a few ways to check this. The first one is to using the corresponding counterpart of the Vanilla JavaScript, it is to check the checked property.$("#checkbox1").prop("checked")The prop() method will get the value of a property for the firs...

15,200 1       JQUERY CHECKBOX CHECKED ATTR PROP


  Let browser prompt for storing password when doing AJAX login

In Web 2.0 era, more and more web applications are using AJAX to replace the traditional HTML form element to perform user login. This usually provides a better user experience than form submission. But it also brings a side effect to the end users. That is the browser will not prompt the user whether s/he wants to save the password so that s/he no needs to enter the username/password again when visiting the same site next time.Below is the code snippet which does the AJAX login. <script style="text/javascript"> $(function () { $('#signin').bind('click', function () { //Sub...

4,214 0       AJAX BROWSER PASSWORD LOGIN


  ScrollerJS vs Odometer

Both ScrollerJS and Odometer are two JavaScript libraries to transition one number to another number with animation. They provide user a fancy animation about scrolling numbers. These libraries can be used in many scenarios such as user statistic counter, timer or odometer.This post is going to have a comparison on these two open source libraries. Below is a table which lists the features the two libraries have:FeatureScrollerJSOdometerLanguageJavaScript and CSSJavaScript and CSSSizeAround 10KB(Minified)Less than 3KB(Minified)LogicSupport both CSS transition and traditional DOM position(top) t...

14,765 0       JAVASCRIPT ODOMETER SCROLLERJS OPEN SOURCE CSS TRANSITION


  Ensure triggering transitionend event in JavaScript

CSS3 Transition has been widely used in modern web app development to offer users animations. Traditionally animations of element in HTML are controlled by JavaScript. If fancy animation is desired, then third party plugins can be installed in browsers such as Flash, Silverlight, Java Applet etc. With CSS3, animations can be easily achieved like a charm.Transition is one of the many features provided by CSS3. It can be used to transit one element from one state to another state smoothly within a specified time. Usually we are not satisfied with just seeing the animation, we frequently want to ...

8,466 5       CSS3 TRANSITION TRANSITIONEND FORCE FIRE TRANSITIONEND


  Why 0.1+0.2 != 0.3

In programming languages such as JavaScript, c/c++, Java and Matlab, you will find that you will get unexpected result when doing float point calculation. For example, when calculating 0.1 + 0.1, you will not get 0.3:> 0.1 + 0.2 == 0.3false> 0.1 + 0.20.30000000000000004Don't be surprised of this result, this is the end result of IEEE 754 standard, float point number cannot be accurately represented according to IEEE 754 because:No enough memory is allocated for representing the numberIt needs a range to ensure the accuracyJavaScript uses 64-bit floating point representation, which is the...

9,622 0       JAVASCRIPT FLOAT POINT COMPARISON