There’s a problem on leetcode (and I imagine many other places as well) called “Predict the Winner.” If you’re unfamiliar with it, here’s the problem description: You are given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array, followed by the player 2,…
True private variables in JavaScript with prototype
This post was originally published on my old back on September 26th, 2011. The content provided here is a republishing of the original post. Most folks know how to mimic public, private, and “privileged” variables in Javascript, but I think at some point, when getting familiar with prototypal inheritance, most scripters wonder if there is…
JSX without React
Did you know you can use JSX without React? If you don’t know what JSX is, this except from DRAFT: JSX Specification located at https://github.com/facebook/jsx may help: JSX is a XML-like syntax extension to ECMAScript without any defined semantics. It’s NOT intended to be implemented by engines or browsers. It’s NOT a proposal to incorporate…
Preventing the default action in JavaScript
This post was original published on my old blog on Friday, June 23rd, 2006. The content provided here is a republishing of the original content. Preventing the Default Action in JavaScript: A few days ago, a friend of mine sent me a nifty “view switcher” he wrote in javascript. Unfortunately, he was having a problem…