Javascript took a lot of design decisions that were more appropriate to a single-application embedded scripting language than a general-purpose programming language. That's not a criticism of its original designers, but it is worth knowing when choosing a general-purpose programming language.