getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.
Other
178.28k stars 33.42k forks source link

Chapter 3: Correction in string indexOf (edition 1) #1656

Closed hello2parth closed 4 years ago

hello2parth commented 4 years ago

var a = 'abc';

console.log(a.indexOf('c')) //2

Yes, I promise I've read the Contributions Guidelines (please feel free to remove this line).

Specifically quoting these guidelines regarding typos:

Typos?

Please don't worry about minor text typos. These will almost certainly be caught during the editing process.

If you're going to submit a PR for typo fixes, please be measured in doing so by collecting several small changes into a single PR (in separate commits). Or, just don't even worry about them for now, because we'll get to them later. I promise.


Please type "I already searched for this issue":

Edition: (pull requests not accepted for previous editions)

Book Title: You Don't Know JS

Chapter: 3

Section Title: Types & Grammar

Topic: Native Prototypes

https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/types%20%26%20grammar/ch3.md#native-prototypes

getify commented 4 years ago

There's a space at the beginning of the string literal in the original book text, so 3 is the correct index position. Moreover, as stated in the pre-filled text, I'm not accepting fixes to the first edition books anymore, since they're all being re-written for second edition.