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

SEARCH KEYWORD -- closure



  JavaScript: Private variables

The first thing you often hear when talking about JavaScript is often “JavaScript doesn’t have visibility modifiers, hence it doesn’t support private variables”. This is only valid for 50%, because JavaScript indeed doesn’t have visibility modifiers (public, private, friend) but it has closures and function scopes. With these tools we can make variables private. Let’s take the following function: var names = ["Kenneth", "John", "Marc", "Robert"]; var lookup =...

   JavaScript,private variable,closure     2012-04-28 11:46:34

  PHP 7 is coming soon

After a few RCs, PHP 7 will be officially released on November 12, 2015. This is a major release of PHP since PHP 5.6. @Laruence, one of the core contributors of PHP, has posted this news on Weibo(China's Twitter).  This is a one month later than the expected time as recorded in PHP 7 timeline. But it's not that late. The new release will come with a few features including: Scalar type declaration, you can define variable like int now Return type support. Besides declare scalar type ...

   RELEASE DATE,PHP7     2015-11-08 09:13:37

  Understanding JavaScript closure and where it can be used

Closure The official definition of closure is: an expression (usually a function) that has many variables and is bound to an environment that includes those variables. In JavaScript, closure refers to the ability of a function to access the lexical scope in which it was defined, even after the function has been executed and left that scope. This ability is due to the fact that when a function is created, it generates a closure that includes a reference to the definition environment of the curr...

   CLOSURE,JAVASCRIPT,USAGE     2023-03-05 02:17:08

  JavaScript-style object literals in PHP

The object literal notation in JavaScript looks like: var fido = {name: "Fido", barks: true}; or var fido = {}; fido.name = "Fido"; fido.barks = true; From assoc arrays to objects In PHP you would call that an associative array. $fido = array( 'name' => "Fido", 'barks' => true ); And you can easily make it an object too: $fido = (object)$fido; echo gettype($fido); // "object" Or if you want to start with a blank object and add stuff to it: $fido = (object)array(); or $fido...

   PHP,JavaScript,Object,Function call,Self vs this     2011-11-30 11:11:45

  What to Look for in PHP 5.4.0

PHP 5.4.0 will arrive soon. The PHP team is working to bring to some very nice presents to PHP developers. In the previous release of 5.3.0 they had added a few language changes. This version is no different. Some of the other changes include the ability to use DTrace for watching PHP apps in BSD variants (there is a loadable kernel module for Linux folks). This release features many speed and security improvements along with some phasing out of older language features (Y2K ...

   PHP,5.4,New feature,Built-in server,Trait     2011-12-21 10:20:12

  What's Wrong with the For Loop

Closures in Java are a hot topic of late. A few really smart people are drafting a proposal to add closures to a future version of the language. However, the proposed syntax and the linguistic addition are getting a lot of push back from many Java programmers. Today, Elliotte Rusty Harold posted his doubts about the merits of closures in Java. Specifically, he asks "Why Hate the for Loop?": I don’t know what it is some people have against for loops that they’re so eager to...

   For loop,Basic,Problem,Efficiency,Java     2012-02-24 05:06:15

  Do things, tell people.

These are the only things you need to do to be successful*. You can get away with just doing one of the two, but that's rare, and usually someone else is doing the other part for you. If you you don't have any marketable skills, learn some. It's the future. We have Khan Academy and Wikipedia and Codecademy and almost the entire world's collective knowledge at your fingertips. Use it. Then make something that you can talk about. Make something cool. Something interesting. Spend time on it. Go ...

   Tihings,Promote,Product,Open source     2012-02-21 05:28:39

  Google will close shopping search service in China

Google vice president of products Sameer Samat posted a news on Google Blackboard, since the service failed to meet the expectations, in order to better optimize resources, Google decided to close the shopping search service in China.In order to better optimize resources, we have decided to close the shopping search service in China. The original intention of the development of this product is to set up a bridge between consumers and retailers and traders. However it did not meet our expectatio...

   Shopping search service, Google China     2012-12-12 14:30:44

  IE ActiveX(”htmlfile”) Transport, Part II

In my last post I discussed using the ActiveX(”htmlfile”) technique to provide a usable streaming transport in Internet Explorer. The solution I provided will work, but since writing the last article I’ve made significant progress in understanding why IE behaves the way it does with respect to the streaming transport. The previous solution amounted to creating an array of messages, pushing messages on that array from the htmlfile iframe, and popping messages off of the array i...

   IE,Http,Streaming,htmlfile,Transport,Act     2011-09-05 04:07:02

  JavaScript interview questions

This post will cover the JavaScript questions I have encountered and have seen during my programming career. They will mainly focus on vanilla JavaScript though there are lots of excellent frameworks out there and many people are using them in their daily work. this keyword this keyword is an very important but easy to confuse concept in JavaScript since it is always referring to the calling object of the function. 1. What will be the output of below code snippet? function User(name) { this....

   JAVASCRIPT,ALGORITHM,THIS,CLOSURE     2019-03-09 07:05:46