01 2016 档案

摘要:Three methods to preform redirection in browser: widnow.location.href window.location.assign window.location.replace 1 & 2, they are pretty much the s 阅读全文
posted @ 2016-01-31 17:51 Zhentiw 编辑
摘要:Learn how to avoid the boilerplate of passing the props down the intermediate components by introducing more container components. Code to be refactor 阅读全文
posted @ 2016-01-29 16:56 Zhentiw 编辑
摘要:var str = "Is this This?"; //var regex = new RegExp("is", "gi"); var regex = /is/gi; //console.log(regex.test(str)); console.log(regex.exec(str)); //[ 阅读全文
posted @ 2016-01-29 05:15 Zhentiw 编辑
摘要:Local Storage is a native JavaScript Web API that makes it easy to store and persist data (as key-value pairs) in the Browser. In this lesson, we'll w 阅读全文
posted @ 2016-01-27 21:44 Zhentiw 编辑
摘要:JSON (JavaScript Object Notation) is a standard method to serialize JavaScript objects and is commonly used to transfer data from the server to the br 阅读全文
posted @ 2016-01-27 20:31 Zhentiw 编辑
摘要:Finally, I just noticed that the to-do app component doesn't actually have to be a class. I can turn it into a function. I prefer to-do that when poss 阅读全文
posted @ 2016-01-27 20:18 Zhentiw 编辑
摘要:Code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { todos, visibilityFilter } = this.props; const visibleT 阅读全文
posted @ 2016-01-27 20:10 Zhentiw 编辑
摘要:Code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { todos, visibilityFilter } = this.props; const visibleT 阅读全文
posted @ 2016-01-27 19:09 Zhentiw 编辑
摘要:The code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { todos, visibilityFilter } = this.props; const visi 阅读全文
posted @ 2016-01-27 18:22 Zhentiw 编辑
摘要:Javascript with Chorme v8 engine works like this :For Chorme engine, v8, it has call stack.And all the async opreations functions are stay in webapis.... 阅读全文
posted @ 2016-01-26 21:12 Zhentiw 编辑
摘要:Every time when a function run it will be push into the call stack and put on the top, you can think call stack is something like a heap... Javascirpt... 阅读全文
posted @ 2016-01-26 20:44 Zhentiw 编辑
摘要:The guiding principle in Cycle.js is we want to separate logic from effects. This first part here was logical, and this second part here was effects. ... 阅读全文
posted @ 2016-01-26 19:09 Zhentiw 编辑
摘要:/** * A reducer for a single todo * @param state * @param action * @returns {*} */const todo = ( state, action ) => { switch ( action.type ) { ... 阅读全文
posted @ 2016-01-15 16:48 Zhentiw 编辑
摘要:In JavaScript, you can change the content of a string using thereplacemethod. This method signature is overloaded with a bunch of different ways to do... 阅读全文
posted @ 2016-01-15 02:13 Zhentiw 编辑
摘要:var input = "foobar";var result = input.replace('bar', '$`'); // $`: replace 'bar' with everything before our match.--> foofoovar input = "foobarbaz"... 阅读全文
posted @ 2016-01-15 02:06 Zhentiw 编辑
摘要:Learn how to use array reduction to create functional pipelines by composing arrays of functions.const increase = (input) => { return input + 1;}cons... 阅读全文
posted @ 2016-01-15 01:37 Zhentiw 编辑
摘要:Example 1:function *topicList(){ yield "ES2015"; yield "Semi-colons: good or bad?"; yield "TypeScript";}for( let topic of topicList() ){ console.l... 阅读全文
posted @ 2016-01-14 21:16 Zhentiw 编辑
摘要:Iterables return an iterator object. This object knows how to access items from a collection 1 at a time, while keeping track of its current position ... 阅读全文
posted @ 2016-01-14 21:07 Zhentiw 编辑
摘要:How to use:export default function getReplies(topicId){ return new Promise(function( resolve, reject ){ _getRepliesForTopic(topicId, function(data... 阅读全文
posted @ 2016-01-14 20:54 Zhentiw 编辑
摘要:Export variable:export const MAX_USERS = 3;export const MAX_REPLIES = 3;Export default class:export default class FlashMessage { constructor(message)... 阅读全文
posted @ 2016-01-14 20:34 Zhentiw 编辑
摘要:Default export:Default export is easy way to export a function to outside module.//flash-message.jsexport default function(message){ alert(message);... 阅读全文
posted @ 2016-01-14 20:17 Zhentiw 编辑
摘要:In constructor, you can call parent's constuctor() method by supert();class ShoppingCart { constructor(userId){ this.userId = userId; this.prod... 阅读全文
posted @ 2016-01-14 20:02 Zhentiw 编辑
摘要:Limitations With ArrayArrays don't enforce uniqueness of items. Diplicate entries are allowed.Using Setslet tags = new Set() ;tags.add('Javascript');t... 阅读全文
posted @ 2016-01-14 04:11 Zhentiw 编辑
摘要:WeakMap: is a type of Map where only objects can be passed as keys. Primitive data type -- such are string, numbers, booleans, etc --- are not allowed... 阅读全文
posted @ 2016-01-14 04:07 Zhentiw 编辑
摘要:Use Maps when keys are unknown until runtime:Map:let recentPosts = new Map();createPost( newPost, (data)=>{ // Key unknown until runtime, so use Ma... 阅读全文
posted @ 2016-01-14 03:35 Zhentiw 编辑
摘要:A common problem when dealing with some kinds of data is that not every object has the same nested structure. lukeskywalker.parents.father.isjedi work... 阅读全文
posted @ 2016-01-14 03:19 Zhentiw 编辑
摘要:Map is really useful when you want to use object as a key to set vaule, in ES5, you cannot really use object as a key:var user1 = { name: "Wan", age... 阅读全文
posted @ 2016-01-13 02:42 Zhentiw 编辑
摘要:/** * A reducer for a single todo * @param state * @param action * @returns {*} */const todo = ( state, action ) => { switch ( action.type ) { ... 阅读全文
posted @ 2016-01-12 19:49 Zhentiw 编辑
摘要:Learn how to create a React todo list application using the reducers we wrote before./** * A reducer for a single todo * @param state * @param action ... 阅读全文
posted @ 2016-01-12 18:11 Zhentiw 编辑
摘要:Sometimes we want to test our Redux reducers to make sure they work as expected. In this lesson we will walk through setting up some Redux reducer tes... 阅读全文
posted @ 2016-01-12 03:21 Zhentiw 编辑
摘要:When using Redux, we can test that our application state changes are working by testing that dispatching actions to the store creates our expected out... 阅读全文
posted @ 2016-01-11 17:06 Zhentiw 编辑
摘要:.blue{ color: blue}.bold{ font-weight: bold;}.large{ font-size: 40px;}ngClass can accept an array:ngClassngClass can take a string:ngClassngClas... 阅读全文
posted @ 2016-01-10 16:06 Zhentiw 编辑
摘要:When testing React components, we often want to make sure the rendered output of the component matches what we expect. With the React Shallow Renderer... 阅读全文
posted @ 2016-01-07 16:53 Zhentiw 编辑
摘要:Setting up a shallow renderer for each test can be redundant, especially when trying to write similar tests that have slight tweaks. In this lesson, w... 阅读全文
posted @ 2016-01-07 15:12 Zhentiw 编辑
摘要:Often our components have output that shows differently depending on the props it is given; in this lesson, we go over how to compare theclassNameprop... 阅读全文
posted @ 2016-01-07 03:52 Zhentiw 编辑
摘要:The React Shallow Renderer test utility lets us inspect the output of a component one level deep. In this lesson, we will examine the rendered output ... 阅读全文
posted @ 2016-01-07 03:37 Zhentiw 编辑
摘要:somereturns abooleanvalue after passing each item in the source array through the test function that you pass in as the first parameter. This makes it... 阅读全文
posted @ 2016-01-06 15:32 Zhentiw 编辑
摘要:When you render a component with the Shallow Renderer, you have access to the underlying object. We can write lots of useful tests to check that our c... 阅读全文
posted @ 2016-01-05 02:26 Zhentiw 编辑
摘要:When writing React component tests, it can be hard to decipher the error diffs of broken tests, since they are just the final objects that React uses ... 阅读全文
posted @ 2016-01-05 01:54 Zhentiw 编辑
摘要:In this lesson, we walk through how to use one of React's Test Utilities (from thereact-addons-test-utilspackage) called "Shallow Rendering". This let... 阅读全文
posted @ 2016-01-05 01:23 Zhentiw 编辑
摘要:JSON(JavaScript Object Notation) is a standard method to serialize JavaScript objects and is commonly used to transfer data from the server to the bro... 阅读全文
posted @ 2016-01-04 04:18 Zhentiw 编辑
摘要:To write tests for our React code, we need to first install some libraries for running tests and writing assertions. In this lesson we walk through se... 阅读全文
posted @ 2016-01-04 03:59 Zhentiw 编辑
摘要:We can use the destructing and rest parameters at the same time when dealing with Array opration.Example 1:let [first, ...remainingUsers] = ["Sam", "T... 阅读全文
posted @ 2016-01-04 03:21 Zhentiw 编辑
摘要:function spinner(target, options = {}){ let defaults = { message: "Please wait", spinningSpeed: 5, cssClass: ".is-spinning" }; let setting... 阅读全文
posted @ 2016-01-03 17:09 Zhentiw 编辑
摘要:Creating Object:Example 1:let name = "Brook";let totalReplies = 249;let avatar = "/users/avatars/brook-user-1.jpg";let user = {name, totalReplies, ava... 阅读全文
posted @ 2016-01-03 16:53 Zhentiw 编辑
摘要:The spread operator allow us to split an Array arguement into individual elements.getRequest("/topics/17/tags", function(data){ let tags = data.tag... 阅读全文
posted @ 2016-01-03 16:32 Zhentiw 编辑
摘要:Problem with the ES5:function displayTags(){ for (let i in arguments) { let tag = arguments[i]; _addToTopic(tag); }}Hard to tell w... 阅读全文
posted @ 2016-01-02 21:47 Zhentiw 编辑
摘要:1. Default Value of function param:The functiondisplayTopicsPreview()raises an error on the very first line when called with no arguments. Let's fix t... 阅读全文
posted @ 2016-01-02 04:59 Zhentiw 编辑

点击右上角即可分享
微信分享提示