When I ask interview candidates to explain what prototypes mean in JavaScript, the response is often something like this
Here's my attempt to explain it succinctly.
I think it's important to draw the distinction between 2 related concepts: the prototype property of functions, and the prototype of an object
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Jasmine Spec Runner</title> | |
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png"> | |
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css"> | |
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script> | |
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script> |
package net.bruceharris.test.inheritance; | |
import static org.junit.Assert.assertEquals; | |
import org.junit.Assert; | |
import org.junit.Test; | |
public class InheritanceTest { | |
private Child c = new Child(); |
Meteor namespacing, specifically package scope variables, don't seem to work as described in the namespacing section of the docs.
From what I can tell, when the var keyword is omitted, actual globals are created. (I'm running 0.6.5)
To run this:
$ meteor create globalcheck
then copy these files into globalcheck
(overwriting the default files)
http://bl.ocks.org/bruceharris/8423028
This simple line chart is constructed from a TSV file storing the closing value of AAPL stock over the last few years. The chart employs conventional margins and a number of D3 features:
- d3.tsv - load and parse data
- d3.time.format - parse dates
- d3.time.scale - x-position encoding
- d3.scale.linear - y-position encoding
- d3.extent - compute domains
- d3.svg.axis - display axes
// Promise.all is good for executing many promises at once | |
Promise.all([ | |
promise1, | |
promise2 | |
]); | |
// Promise.resolve is good for wrapping synchronous code | |
Promise.resolve().then(function () { | |
if (somethingIsNotRight()) { | |
throw new Error("I will be rejected asynchronously!"); |
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
export default class LoadingIndicator extends Component { | |
render() { | |
return this.props.children; | |
} | |
} | |
LoadingIndicator.propTypes = { |
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
export default class LoadingIndicator extends Component { | |
render() { | |
return null; | |
} | |
} | |
LoadingIndicator.propTypes = { |
import React from 'react'; | |
import { mount } from 'enzyme'; | |
import LoadingIndicator from './LoadingIndicator' | |
describe('LoadingIndicator', () => { | |
describe('when isLoading is false', () => { | |
it('should render children', () => { | |
const wrapper = mount( | |
<LoadingIndicator isLoading={false}> | |
<div>ahoy!</div> |