Coder Social home page Coder Social logo

js's People

Contributors

abhimanyu003 avatar ascott1 avatar bevacqua avatar bttmly avatar contolini avatar doobix avatar homeopatchy avatar hurtak avatar imcotton avatar readmecritic avatar sigod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js's Issues

Style checking is not painful

You need to quantify why style checking is painful. Your statement is especially contradicting as enforcing braces is something that the style tool you link to will actually do. I have never worked in a shop where a style of code wasn't enforced. Agreeing on a style might be arbitrary but it's usually done for a good reason.

Function declarations and hoisting.

I'm confused why a function expression is worse than a function declaration (https://github.com/bevacqua/js#functions). You site hoisting as the reason why they're bad. But aren't function expressions better for this very reason? That is, by declaring the function as a variable, it will remain in the order that it is defined in the scope, rather than switching around as a function declaration would be hoisted above other variable definitions and make the code less clear.

Also, it seems that by defining a function in a variable, one would get better error feedback (for example if someone tried to use the function before it was declared they would get a TypeError).

See http://www.unicodegirl.com/function-statement-versus-function-expression.html

IMHO function expressions make for clearer code as it is closer to what the interpreter is seeing, making the code more predictable and thus easier to manipulate.

This may all be moot with ES6 now standardized and most of the community moving over to block-scoped let, but I'm just curious about your reasoning because I always thought about it the other way around.

Comparison operators

Hi sir,
i am facing the issue at comparison operators.
Comparison operators are not working properly i a function.

alert(1>2); //output is true
//but
function a(){
alert(1>2); //output is null showing alert but not have any value
}

[discussing] can ternary operators be used instead of if/else?

In a reused form component for both the record creation and the record modification, is it acceptable to use ternary operators instead of if/else like this?

this.formAction === 'edit' && this.recordValue ?
    this.recordForm.setValue(this.recordValue) :
    this.recordForm.reset();

It's a clear-cut case. With code-formatting of new-line and indent, it's quite readable. And in the foreseeable future, for each condition of the formAction, the business logic is unlikely to be changed.

Doesn't work on Chrome or IE

if (!car) { return; } if (!black) { return; } if (!turbine) { return; } return 'batman!';

The above code doesn't support many browsers even if we remove the return statements and replace it with console.log.

Brackets on same line? Not recommended.

Under Conditionals, you demonstrate the following, below, as "Good":

if (err) { throw err; }

Yes, the practice of using brackets when they're optional is indeed good.

Aside from that, however, I don't believe opening and closing curly brackets should ever be on the same line, as a rule. It encourages poor readability.

When you're visually scanning code, this is much harder to parse:

if (a === b) { doSomething(); }
else if (a === c) { doSomethingElse(); }
else { doTheThing(); }

Than this:

if (a === b) { 
    doSomething();
}
else if (a === c) { 
    doSomethingElse();
}
else {
    doTheThing();
}

Or even this:

if (a === b) { 
    doSomething();
} else if (a === c) { 
    doSomethingElse();
} else {
    doTheThing();
}

Density is not a good thing.

Keeping code terse and line numbers down can sometimes be counter-productive. Same-line opening/closing brackets give developers the illusion of a code block having less logic in it than it actually has.

If I see a method with three lines as I'm scanning, I will likely perceive the complexity to be less than if I see a method that does the exact same thing but is nine lines. The risk is that other developers will come along and stuff more logic into that method with three lines than the one with nine. Code blocks with same-line open/close brackets end up growing larger in complexity, discouraging abstraction and separation of concerns.

White space, on the other hand, is a good thing.

Question

@bevacqua Thanks for the amazing work done.

Use Function() as a "no-op".

function (cb) {
  setTimeout(cb || Function(), 2000);
}

why not use if-else and do not call setTimeout at all ?

Adding New Feature in Doc

Can we Add length literal in Array i.e will Help to find the length of Array.

array.length
return : x: size of Array

Can I mix colors by using js?

I want to mix two or three colors to one color.
I don’t care about color components(Using r,g,b or other things)

If there is any way to do this, please let me know!
thanks,

typo

Linting section ,first line

On the other hand?

8

بلاي][هكر[توب

Functions in README

When declaring a function, always use the function expression form instead of function declarations.

Yet underneath you show that var foo = function(){}; is bad whilefoo function(){}; is good

I thought function expression is the storing of anonymous or named functions in a variable and function declaration is a named function without a variable assignment.

ASI

Automatic Semicolon Insertion (ASI) is not a feature. Don't rely on it. It's super complicated and there's no practical reason to burden all of the developers in a team for not possessing the frivolous knowledge of how ASI works. Avoid headaches, avoid ASI.

Always add semicolons where needed

To quote standard out of laziness:

No semicolonsIt's fine. Really!

There is only a single rule that is a real "gotcha!" and memorizing a single rule is not "frivolous knowledge of ASI".

I'm impartial about whether to avoid or use semicolons. However spreading FUD as the reason to use them should not be how a responsible developer does it. It's largely a stylistic issue. Feel free to advocate for the use of semi-colons but please make sure you aren't doing so under false reasons.

Regardless, I'd take a programmer with frivolous knowledge of how a language actually parses and functions over one who doesn't any day of the week.

Relevant to above statement:
http://www.slideshare.net/olvemaudal/deep-c

Address performance hit of [].slice.call(arguments)

There is a substantial performance hit associated with using arguments in certain ways, as outlined in this great post. While [].slice.call(arguments) is the cleanest way to cast arguments to an array, and in many cases it's not necessary to fully optimize, I think it's at least worth mentioning.

Default value

I don't think it's good to recommend using || for setting default value to variables. It's nice shortcut but it can cause trouble when valid input (0, false, '') is converted to default value. I would recommend mentioning explicitly these dangers in that chapter or add chapter about more safe default value assigning

function example(value) {
  if (typeof value === 'undefined') {
    value = 'defaultValue';
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.