Coding Category Archives - General Assembly Blog

What Is coding?

By , and

Coding is a language, simply put. But that doesn’t stop the mysteries and the global misconceptions that swirl around it. Too often, coding is presented as difficult to understand and needlessly complicated. Why does coding have such a mystique?

Shahzad Khan, one of our lead instructors, breaks it down:

“People think that coding is about sitting in a dark room writing thousands of lines of incomprehensible code. It’s not.” Khan has built a career on breaking down the complicated concepts of coding into easily understood concepts in our Introduction to Coding course, which allows students to dive right into learning programming language. “With the new high-level languages like Javascript and Python, coding is more intuitive and closer to the English language than it has ever been.”

Just like with other languages, once you learn a coding language and how to use the tools of computer science to communicate, a whole new world opens up.

Coders have been known to perpetuate the mythology, though. When they talk about coding, practitioners can sound like proselytizers. They tell passionate stories of how coding has changed their lives — and the world. Famous lines of code have become legendary. Look no further than the Facebook “like” button, an example of how the most consequential code changes people’s behaviors. That’s a lot of power, and it can be intoxicating.

Steve Jobs famously claimed that everyone should learn how to write code because learning how to code teaches you how to think. That may be true, but this definition of coding is still our favorite: Coding is solving real-world problems with existing technology.

And the barriers to entry are relatively low. “Coding is awesome because it allows you to build some amazing things as long as you have a working computer and the internet. No need to go invest in expensive equipment,” says Khan. 

“Software is eating the world, so coding is already extremely important and will be even more so as we progress into the future. The right people who know how to code will save the world.”

The fact is that software is only getting more ubiquitous, finding its way into government and public policy. One look at the United States’ patchwork response to COVID-19, and it’s not hard to imagine how the right software at the right time could have lifesaving implications.

For others, coding is a calling and a way to express creativity — not something you usually associate with computer science. “Creating something is so satisfying, and coding is the ultimate tool to do that,” says Arwa Lokhandwala, one of our lead instructors:  “I love getting my hands dirty trying to learn how to use a particular technology to solve a problem or just creating something for fun.”

Coding isn’t a solitary, head-down endeavor, contrary to those popular misconceptions. We can dispel the image of the glassy-eyed, hoodie-wearing loner right here. “There is a common myth that coders work alone,” Lokhandwala continues. “That’s not true! Coding is a very collaborative role. You have to interact with your team members, designers, product owners, and stakeholders, to name a few.”

“We are entering the Fourth Industrial Revolution where technology will dominate every domain. Currently, people are using coding for everything from detecting diseases to exploring outer space. This is just the beginning. Coding is completely going to revolutionize every industry and give birth to new ones.”

Ready to learn? Enrolling in a coding bootcamp is a great way to learn coding without investing years or thousands of dollars. At GA, a coding bootcamp can be 12 or 15 weeks long and is designed to be a fast-paced learning experience. Students learn and implement quicker than in more traditional courses, and the most successful learn to trust the process. Our Software Engineering Immersive course gives students all the coding skills they need to start job hunting and is Khan’s favorite course to teach. “I love that I get to make an immediate impact in the lives of people who come to learn and want to change their lives for the better.”

Want to learn more about Arwa?

https://www.linkedin.com/in/arwalokhandwala-b831b/

https://www.instagram.com/code.with.arwa/

Want to learn more about Shahzad?

https://www.linkedin.com/in/shahzadkhanaustin/

https://flawgical.medium.com

How long does it take to learn coding?

By , and

How long does it actually take to learn coding? To create a diverse portfolio that wows clients, you’ll want to showcase your talents on varying platforms. But first, you’ll need to assemble your coding toolkit. The most efficient approach for beginners is to pick one programming language and try to master it. So, what can you expect next?

Since everyone’s learning style is different, the time commitment required to learn coding can vary. Some people will pick up a new coding language in days, while for others, it could take months. Taking a course specific to Python or JavaScript will teach you the core concepts of that language and how to write programs in those languages. Expect a bit of a learning curve as you train your mind to think like a programmer. But it’s all part of the process. In our coding courses, you’ll gain broad benefits that set you up for workplace success. You’ll learn best practices, get feedback from peers and experts, build a network, and receive career coaching.

Shahzad Khan, lead instructor and owner of software development and consulting firm Frame of Mind considers coding to be a life-long learning process. “Coding is a way of thinking rather than a thing you learn and implement. Once you understand that, it’s just a matter of practice. Some students will arrive at that “a-ha” moment faster than others.“

For those who can invest more time upfront, Khan recommends the intense learning environment of a bootcamp like our Software Engineering Immersive (SEI), which gives  all the coding skills for full-stack web development. 

“SEI will teach you everything from how to ideate and think about the user to how to implement design patterns and deploy the application to the cloud,” he says. “All that, in a nutshell, is full-stack development. You will learn at least two languages and their respective frameworks. There is also time dedicated to computer science fundamentals, so graduates have a robust exposure to concepts as they interview for their first role as software developers.” 

When Python instructor, Diego Rodriguez, was working as a data analyst, he used coding to get his job done faster. “I was doing many repetitive data analysis tasks, and I knew that if I could code, I could not only get through them quicker, but I could teach others to do the same. I read “The 4-Hour Workweek” by Tim Ferriss, and that shaped my perspective on how to work. I realized that coding would allow me to do more in less time.”

He encourages beginners to start with the fundamentals and apply learning code to a personal project for the most successful — and efficient — approach.

“In as little as two weeks, you can learn enough to take on small projects like creating data visualizations using structured data. If you’re learning with a specific goal in mind, you can focus on accomplishing each step of the workflow using code.”

Rodriguez breaks down just how long it takes to learn the programming language Python here. 

Explore Coding Workshops

Want to learn more about Shahzad?

https://www.linkedin.com/in/shahzadkhanaustin/
https://flawgical.medium.com

Want to learn more about Diego?

https://www.linkedin.com/in/rodriguezadiego/

How To Learn Coding

By , and

Do you know how to use a computer? Do you have a curious mind? If you answered yes to both, you have everything you need to learn a programming language and become a coder. Coding is very accessible — it’s really that simple.

There are many ways to learn to code, from going it alone on a DIY coding website to scoring a coveted spot in a computer science doctoral program. Learning along with others and from an instructor who is passionate, knowledgeable, and has real-world experience creates our dynamic General Assembly environment. From a bootcamp Immersive to a classic Introduction to Coding, our coding courses are taught by professionals who are industry leaders. Essential is their own love of learning, and they thrive on sharing this with students, often in a collaborative discussion that covers a wide range of coding topics.

Lead Instructor at General Assembly Singapore, Arwa Lokhandwala, is a full-stack web developer and advocate for women in technology through groups like the Women Techmakers Community and Mumbai Women Coders. She describes herself as a coder at heart with a passion for sharing. We trust her guidance on all things coding.

“Anyone with a passion for learning new things can learn how to code, “ says Lokhandwala. “You don’t need a 4-year degree. Familiarity with computer science is good to have, but it’s not necessary; you can learn that as you go along. A lot of companies hire people directly from a coding bootcamp.”

“Bootcamps are inherently intense because there is a limited time period to train, which has its own advantages. The initial days are challenging, but as you progress with the projects you build, the people you interact with, and the things you learn, you will become confident with interviewing and getting the job. If you are just starting out with coding, I would highly recommend a GA Immersive because it gives you a community. Talking to other people who are in the same situation as you can help you get motivated.”

There is no one-size-fits-all, ideal coding student. Students at GA have come from all walks of life, from service industries to liberal arts backgrounds to working on an oil rig. Lokhandwala describes what makes a student successful. “Never giving up. Coding is hard, and nobody gets it on their first attempt. So don’t let your imposter syndrome get the better of you. Keep practicing, and you will get it. Your intrinsic motivation to code has to be stronger than the external motivation in order to create a fulfilling career.” 

Shahzad Khan, one of our lead instructors and owner of software development and consulting firm Frame of Mind, appreciates the experience that students from non-traditional backgrounds bring to his Introduction to Coding course at our Austin, Texas campus. Khan got a degree in philosophy and began studying programming languages as a way to gain acumen after graduate school. “I saw coding as something I needed to learn in a world where we are surrounded by software.” 

His passion for teaching makes his courses popular among returning students.

“I love teaching programming because it forces me to learn every single day and to think about different ways to explain complex concepts. Plus, I get to make some genuine connections with students and inspire them to awesome things.”

Explore Coding Workshops

Want to learn more about Arwa?

https://www.linkedin.com/in/arwalokhandwala-b831b/
https://www.instagram.com/code.with.arwa/

Want to learn more about Shahzad?

https://www.linkedin.com/in/shahzadkhanaustin/
https://flawgical.medium.com

What can you do with coding?

By and

What do the most in-demand 2021 jobs and promising careers of the future have in common? Coding skills. At the same time, new applications of coding are making their way into existing roles, expanding job requirements in traditional fields like banking and marketing. Even for non-tech roles, coding skills are seen as a valuable bonus that can give job candidates an edge.

Our digital world buzzes with software code we use every day, from products and services in the form of websites to mobile applications to games and on and on. 

Computer programmer, developer, engineer, analyst  — these are just some of the titles rapidly populating the job boards of Fortune 500 companies, and coding skills are essential requirements in all of them. Arwa Lokhandwala, who teaches our popular Full-Stack Web Development course, breaks down the various titles and what they really mean.

“Most of these terms are used synonymously, but there is some slight difference between them. A computer programmer, for instance, includes anyone who uses a programming language to produce some digital output — this technically includes everyone who codes. A developer uses a wide array of technical abilities, from writing code and creating technical documentation to testing and debugging. An engineer, on the other hand, is a person who has a strong educational background in software engineering, computer science, and mathematics and can apply these concepts to solve or create digital solutions. Finally, the analyst’s main job is to analyze different metrics, understand data captured by these digital solutions, and derive useful insights from them that are beneficial for the business.”

Additional jobs for coding professionals include web designer, software engineer, and chief technology officer (CTO); myriad roles in the fields of web development, technical project management, and quality assurance; plus, almost every founder of a successful startup has a background in coding.

So, what does a typical career path look like? “You can either start out as a software engineer, software developer, or quality analyst. As you progress, you can become lead developer then either go towards becoming an engineering manager, solution architect or product manager,” Lokhandwala advises.

You don’t always have to make a big move to flex your coding muscles. Often newfound coding skills can help you to advance in your existing job. If you’re curious about how this may pertain to you, Lokhandwala suggests offering to solve a particular problem at your company that you think can be automated with coding and see how that affects your role. The next step would be to take a course in a programming language like Python or fast-track your career with a coding bootcamp like our Software Engineering Immersive. Whether you stay at your job or accept a better offer elsewhere, you’ll gain a distinct advantage in the job market and increase your earning potential.

The practical applications for coding language are vast and growing every day. From medical coding to building websites, freelance to full-time, the jobs that use hard coding skills are varied enough to fit every personality and lifestyle.

Lokhandwala sees many exciting new uses of coding on the horizon, all on the cutting edge of computer science. “Some of the most interesting are in the realms of augmented reality and virtual reality. Using artificial intelligence and machine learning to identify the early onset of diseases has huge implications.”

Explore Coding Workshops

Want to learn more about Arwa?

https://www.linkedin.com/in/arwalokhandwala-b831b/
https://www.instagram.com/code.with.arwa/

Which coding language should you learn?

By and

Python, Pandas, JavaScript, Django, Go… the many computer programming languages can be overwhelming to newbies. So, which coding course should you enroll in first? Is there a basic coding language, or should you try to learn the one you hear everyone talking about? Even for those with a working knowledge of computer science, it can be challenging to keep up with the latest buzzwords and advances in the exciting, ever-evolving field of coding.

That’s why we’ve turned to an expert. Diego Rodriguez, data scientist and Python instructor, is here to help answer our most pressing questions.  

What do beginners need to know about learning a coding language?

DR: Learning programming languages can be intimidating, so it helps to know a little bit about them to make the process of learning approachable. It is no different than learning a natural language. You start by learning syntax and basic vocabulary. You apply those concepts effectively, and then you learn new ones. 

There are many programming languages, such as Python, R, Java, C, Go, JavaScript. Each language has an ideal use case. For example, Python and R have become the norm for data analysis. You can certainly do that in Java, but there is a steeper learning curve for Java than there is for Python. 

Which language did you learn first and why?

DR: I took a Java class in high school. I learned the vocabulary and syntax, but I never used it professionally or in academia, so I forgot most of it. In my data science program at General Assembly, I learned Python, and I use it almost every day, so I’d say Python is my first programming language. Python is known as a general-purpose programming language. It’s an instrumental tool for my work in data engineering, data analysis, and data science. 

What is the easiest programming language to learn?

DR: Two easy programming languages to learn are Python and R, primarily because of their readability and all the learning resources that are out there. HTML, CSS, and JavaScript are all easy (and important) to learn for front-end web development. If you end up picking a language and decide it was the wrong language to learn, the good news is it’s much easier to learn another once you have one under your belt.

How have programming languages evolved? What makes one better than another?

DR: Programming languages were created to either suit a specific purpose or as a more general and legible language. For example, Python was inspired by Java and C, and ABC. Every new language builds on its predecessors in some ways. There may be improvements in usability, or speed, or readability. Python, for example, is more readable than other OOPs, but it’s slower to process. On the other hand, Go is similar to Python syntactically and also built on C, but executes much faster.

What is the most challenging aspect of learning to code?

DR: I think new coders can have a hard time figuring out an optimal approach to a coding problem or with debugging their code. You can do a lot with a little bit of coding knowledge, but it’s important to watch out for coding inefficiencies — writing 30 lines of code for something that could’ve been done in two lines. And in regards to debugging, it’s one of the most frustrating things about coding. But over time, you learn to not repeat mistakes and to troubleshoot your code more efficiently. The important thing to keep in mind is that both challenges are part of the learning process. Everyone experiences them!

Is it possible to teach yourself coding?

DR: Sure! I know many coders who are self-taught. But I know more who have had some formal instruction. For those new to coding, it helps a lot to have a curriculum to follow, and it’s even better if you have an instructor to guide you. As you gain coding experience, you will take on new challenges, some of which will require you to learn new techniques, libraries, or even entire programming languages. So having a self-taught mindset is an important part of being a coder. There are no prerequisites to coding, just being curious, patient, and open-minded.

Will coding save the world?

DR: Such an interesting question! I think coding has made life more enjoyable and fruitful. Those who code for a living have made tremendous contributions in fields like STEM, entertainment, transportation, and everything in-between. It’s safe to say that coding has made parts of the world smarter, healthier, and safer. If we as a society ever need saving, code may be the way to go about doing that. Things that are created to allow the survival of mankind will often be technological in nature, and therefore based on code. 

 So, the TL;DR? 

DR: If you take anything away from this conversation, it’s that you should learn to code! I recommend Python! 

Explore Coding Workshops

Want to learn more about Diego?
https://www.linkedin.com/in/rodriguezadiego/

Ways to make money coding

By , and

If computer scientists agree on anything these days, it’s that software is everywhere in our ultra-connected world. Since someone has to write all that software code, there are more ways than ever to make money coding.

And computer science prevails in our ever-shifting world. COVID-19 has revealed our global interdependence on computer science, and there’s no going back. From Roombas to mRNA, the applications of coding have come to define daily life in new ways. One enterprising coder recently made the news using the programming language Python to snag an elusive vaccine appointment in their city.

It’s easy to understand why coding skills are some of the most sought-after in today’s tech job market. So how do you actually make money with coding and start saving the world one line of code at a time? We have the answers.

Once you’ve got a few coding courses or a coding bootcamp under your belt, you’ll have a working coding toolkit that showcases your talent. Now it’s time to think about where you can put your coding skills to work. Job postings for computer programmers and calls for coding skills can be found at almost every company across the globe. Good to know: Some entry-level jobs offer on-the-job training, and you can essentially get paid to learn to code.

The healthcare tech sector has taken off, and this is a trend that beginner coders should watch. Certainly, the pandemic has made it easier to work from home, and coding naturally lends itself to remote work, opening up more job markets in far-flung locations. Even pre-pandemic, medical billing and medical coding were among the 20 fastest-growing tech occupations in the U.S. Now, with the boom in telemedicine and a growing need for data management, health tech remains a promising field for computer science. Vaccine passports and patient privacy concerns present perfect case scenarios for the problem-solving skills inherent in coding and are poised to create opportunities in both public and private sectors. From health data technicians to mobile app developers, the ways to make money coding in health tech are only set to grow. We see the potential for even more innovation because programmers have only begun to push the boundaries at the intersection of medicine and computer science.

Even though a lot of companies have suffered from the pandemic, our data show that the jobs for coding have not been affected nearly as much as other fields. Businesses previously without an online presence are now migrating towards it, giving programmers and coders plenty of new work.

One of our lead instructors, Arwa Lokhandwala, takes stock of the Singapore job market and notes that coding roles can pay very well, adding that, “There are both salaried and hourly options available, and you can also freelance your skills over several freelancing sites.” About half of her students in our Introduction to Coding course are looking for a career change and want to know how hard it is to break into coding. “I think the most difficult thing is the change in mindset when you move from other fields into coding. Keep practicing and keep learning. As long as you are skilled in what you do, the job market will be good to you.”

Most beginner coders know that building websites and web development are avenues now open to them, with even more demand for building mobile applications. Coding opportunities in gaming and game development show no signs of slowing down either. Traditional sectors like finance and banking are ramping up their software development and have a growing need for coders, as more of our day-to-day happens on the go and on our phones. Education has long been a sector ripe for disruption, with the pandemic sending everyone from school administrators to test providers scrambling to adopt technology in new ways.

Data visualization, machine learning, and artificial intelligence are some of the most exciting spaces for coding professionals right now. These fields are breaking new ground, and often, that’s where many thrill-seeking coders want to be.

The high demand for jobs with well-paying salaries is just one of the attractions for coders. Coding draws on problem-solving skills and attracts the intellectually curious. When computer programming is done right, it never gets boring because you are always learning new things. 

“I was attracted to coding because there is a lot of demand for programming,” says Shahzad Khan, who leads our Software Engineering Immersive in Austin, Texas. “But I also wanted to find a job that satiated my problem-solving skills and forced me to keep learning every day.”

Real-world applications of coding are everywhere, but that doesn’t always make them easy to spot. There are ways to make money coding that may not be on your radar yet. Khan names a few less-obvious career opportunities like working with electrical grid systems, charting airplane trajectories, and exploring space. “These days, anything that requires the internet is an application of coding.”

Explore Coding Workshops

Want to learn more about Arwa?

https://www.linkedin.com/in/arwalokhandwala-b831b/
https://www.instagram.com/code.with.arwa/

Want to learn more about Shahzad?

https://www.linkedin.com/in/shahzadkhanaustin/
https://flawgical.medium.com

Why is coding so hard?

By and

Like many subjects in computer science, coding has a reputation for being a difficult skill to master. For many beginning students, its purported difficulty is the elephant in the room. One of the questions we get asked the most is: Are coding and computer programming hard to learn? It won’t be a spoiler to anyone considering this field to say that the answer is complicated.

“Our brains are awesome — they can pretty much learn anything given the right time commitment, “ says Shahzad Khan, our lead software engineering (SEI) instructor and recipient of the Distinguished Faculty Award. “But like learning anything new, you have to give your brain some time to process it, and you have to practice.” 

If you have never, ever coded before, learning to think like a coder can be difficult at first. It helps to think of learning to code like learning a new language: challenging at first but increasingly rewarding as you get more adept and gain confidence in a new vernacular. Once you start speaking it fluently, the language of coding becomes a pleasure like nothing else.

Another question we get asked a lot is: Do I have to be good at math? The answer is a nuanced, “Not necessarily.”

At the base level, programming is built on mathematical foundations. But with programming languages like JavaScript and Python, you won’t need to worry about knowing complex math in order to build software applications. There are plenty of libraries that take care of that for you. 

“People often have an adverse reaction when they see or hear the word math,” says Khan. “Don’t let that get in the way of learning to code. Instead of thinking about being good at math, think about having an appreciation for math. Math is everywhere!”

“If anything, you should think about the difference between arithmetic and math. Two different things that often get mixed up. Arithmetic is when we refer to addition, subtraction, multiplication, and division. Mathematics is reserved for problems involving signs, symbols, and proofs. It’s more theoretical.”

One of Khan’s favorite courses to teach is the Software Engineering Immersive, one of our full-time coding bootcamps. This fast-paced, weeks-long dive into programming can give you a distinct advantage in the job market. “It’s not like traditional schooling,” he says. “You are thrown a lot of information, and you need to trust the process. Make sure to clear up your schedule and prioritize your time to learning coding.”

The truth about coding: “Coding is not for everyone. We are all very unique people with unique skill sets. But coding is not impossible to learn. If you are someone who always needs to be right and doesn’t like to struggle, then you should not enroll.”

As the saying goes, “Anything worth doing is hard.” According to Khan, the most successful coding students are those who love to solve problems.

Explore Coding Workshops

Want to learn more about Shahzad?

https://www.linkedin.com/in/shahzadkhanaustin/
https://flawgical.medium.com

How to get better at coding

By and

You’ve got the coding basics, so what’s the next step? 

Arwa Lokhandwala is a lead instructor at our Singapore campus and also a full-stack web developer deploying scalable web applications that handle an average daily request load of up to a million queries. We asked her about the challenges of learning a programming language — what separates the amateur from the master?

“The mindset. Coding is hard, and it takes multiple attempts in the beginning to understand concepts,” she says. “That’s completely normal. Keep practicing every day, and don’t compare yourself with anybody else.”

One surefire way to get better at coding is by enrolling in a coding bootcamp. These totally Immersive courses are proven to jumpstart your coding skills, and you’ll come away with huge strides in proficiency. The Software Engineering Immersive (SEI) is our most popular 12-week coding bootcamp. All-day, every day, it’s a clear-your-schedule kind of course with commensurate benefits.  

Learning to code is often compared to learning a new language. In the same way that living in a foreign country is the fastest way to learn that country’s language, the immersion of a bootcamp is the fastest way to learning a new programming language and honing your coding skills.

Often getting better at coding means taking on a coding challenge and making lots of mistakes. The learning process at GA involves breaking problems down into small, solvable chunks. “People often are not used to that,” says Shahzad Khan, SEI bootcamp instructor. “You have to be okay with failing and being wrong. Learn to be patient with yourself. You learn by speaking it and by writing in it. Initially, you will sound terrible and use incorrect grammar, but as you speak and write it more, talk to more people, get feedback, and continue to improve, you will eventually feel comfortable with it.” 

The best indicator of success in all coding courses is a willingness to practice. “You can sit and think about a particular coding concept for hours and understand why it works the way it does, but it won’t do you any good until you actually build something using that concept. So, implement what you learn as soon as possible.”

Computer programming can inspire philosophical thinking at its best. If this sounds like coding and its practice can become something of a life philosophy for coders, it is. “To learn coding, you have to open yourself up to feeling like a child again. You have to unlearn some things. It can be an uncomfortable process. Usually, people find it too difficult because it makes them feel too uncomfortable. If you face that discomfort, you can learn anything.”

To get better at coding, coding courses and coding bootcamps can give you the time and focus to chart your path to success. They also provide the environment and community to foster that learning. There is very real work to be done, practice, and lots of iteration. But there is also the metaphysical aspect that famous programmers talk about. You can become a better coder by understanding their insights, too. Like this one by Martin Fowler, software developer and author of nine books, ”Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” And this one from John Johnson, “First, solve the problem. Then, write the code.”

So whether you’re ready to take the plunge with one of our Immersive coding bootcamps or you’re trying to solve a thorny work problem with code, remember to heed Khan’s advice and be patient with yourself. “Coding takes time and practice. You have to believe in yourself. You also need to be comfortable with being vulnerable. If you don’t open yourself up, you will resist change, and that will infiltrate your learning process.“

Explore Coding Workshops

Want to learn more about Arwa?

https://www.linkedin.com/in/arwalokhandwala-b831b/
https://www.instagram.com/code.with.arwa/

Want to learn more about Shahzad?

https://www.linkedin.com/in/shahzadkhanaustin/
https://flawgical.medium.com

Top Five JavaScript Interview Questions

By

JavaScript is one of the most popular programming languages. Even though there are many JavaScript-based frameworks like React.js and Node.js, the ability to answer some core JavaScript questions will always give you an upper hand during an interview.

So, let’s start!

1. What is hoisting?

Hoisting is a default process wherein JavaScript moves all the declarations to the top of the current scope.

Example:

a=20;
console.log(a) // 20
var a;

Even though variable a is initialized and accessed before it’s declared, JavaScript doesn’t throw an error.

2. What is the purpose of closures?

As per MDN Web Docs,

“Closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).” 

In simple terms, Closure is what allows an inner function to access an outer function’s scope, even when the outer function has already returned.

Example:

const cartMode = function() {
    let items=[] // acts like a private variable
    function addItem(item) {
       items.push(item)
       return "Item added to Cart"
    }

    function totalItems() {
      return items.length
    }

    return {
       addItem,
       totalItems
    }

}

const cart=cartMode()
cart.addItem("Bag") // returns Item added to Cart
console.log(cart.items) // returns undefined
cart.totatItems() // returns 1

In the above example, the items variable is accessible to all the inner functions, but it’s not directly accessible from outside. This happens because of closures

3. What is the difference between let, const, var?

Before ES6, JS had no way to support block-level scope variables. Now, we have:

  • var for creating function-level scope variables.
  • let for creating dynamic block-level scope variables.
  • const for creating constant block-level scope variables.

Example:

var a = 20

if(a > 10) {
  let b = 1
  const a = 2

  console.log(b,a, 'Inner Scope')   // 1 2 Inner Scope
}

console.log(a, 'Outer Scope')   // 20 Outer Scope

4. What is the output of the following code?

console.log("1")
setTimeout(function(){
  console.log("2")
},0)
console.log("3")

Output:

"1"
"3"
"2"

Even though we specified the delay as 0ms, it still prints “2” after “3”. This is because of the Event Loop in JavaScript. 

In this case, first, console.log(“1”) is executed, then setTimeout() is executed; after the specified delay (in this case, 0ms), the callback function is added to Message Queue. Now the main thread only picks up items from the message queue once the current execution is done. So, the main thread first evaluates the console.log(“3”) statement post. Then, it picks up the callback() from the Queue and executes the console.log(“2”) statement. Hence, the above output.

5. Difference between arrow functions and regular functions?

Arrow functions are new ES6 syntax for defining functions. It looks like this:

const add = (a,b) => a+b
add(2,3) // 5 

The main difference between the arrow function and regular function is the value of this  keyword.

In case of arrow functions, the this keyword is assigned a value lexically. What this means is unlike regular functions, arrow functions never create their own execution context. They, by default, take the execution context of the enclosing function a.k.a., parent. 

Here is another great article explaining this in-depth. 

Conclusion

Preparing for JavaScript Interviews can feel overwhelming, but the only way to overcome them is to take one concept at a time

Explore Coding Workshops

How to Go From Zero to Hero in JavaScript Fast

By

JavaScript (often shortened to JS) is a lightweight, interpreted, object-oriented language with first-class functions — it is best known as the scripting language for webpages. It is a prototype-based, multi-paradigm scripting language that is dynamic, and it supports object-oriented, imperative, and functional programming styles.

Now, what does all that mean?

Well, it could be a bit overkill to try to explain those topics if you are just starting out in coding or learning JavaScript. In short, JavaScript most often correlates with client-side scripting on webpages. When you use a website, anything you interact with usually involves JavaScript — a search bar on Google or a dropdown menu on Facebook is all JavaScript.

While JavaScript was originally intended for websites, its uses have far surpassed front-end interactive website usage. JavaScript can be used as a server side-language with NodeJS to create desktop and mobile apps or program different electronics (popular YouTuber, Michael Reeves, uses JavaScript on a lot of his quirky inventions). JavaScript has expanded immensely since its inception with tons of different use cases and massive community support.

The Best Places to Learn JavaScript

There are many ways to learn JavaScript — here are some of the best and the most cost-effective ways.

1. Codecademy

Codecademy is a code-learning site that has multiple languages available with interactive and applicable examples. No downloads are necessary; it’s all in your browser! Best of all, it has a lot of free material.

I cannot stress how well Codecademy structures its learning process. I truly believe it gives a strong foundation and teaches you a lot of the basics that you need to get started with JavaScript.

However, just as with any coding language, it can be a little dry and tedious at first. Nonetheless, stick it out and work through the “Learn JavaScript” course:  https://www.codecademy.com/learn/introduction-to-javascript.

At the very least, work up t0 the “Browser Compatibility and Transpilation” section, but by all means, finish the entire course if you are up for it. 

2. freeCodeCamp

freeCodeCamp is very similar to Codecademy in the sense that everything runs in your browser. It has a code editor, console, and example browser window all within site. freeCodeCamp can seem daunting at first due to the sheer amount of content it has, but do not worry. If you are looking to learn JavaScript fast, it has a section called “JavaScript Algorithms and Data Structures Certification” specifically for JavaScript. It will take you through learning the basics of JavaScript and even some in-depth topics such as Data Structures and Algorithms.

Everything else freeCodeCamp has to offer is related to website programming. It even has sections on job hunting. If that is something you are interested in, I would recommend the entire site as it has a lot of great content. FCC also has a Youtube channel: youtube.com/c/freeCodeCamp, where it explains a lot of site topics in a video format.

3. Udemy/Youtube

I put these two in the same category since there is a lot of overlap, and you will see that a lot of people on Udemy use Youtube almost like a marketing tool for their full course. Nonetheless, a lot of Udemy courses range from $10–15 with a lot of good material. Really, one or two courses should be enough to learn JavaScript, so there is no need to spend a fortune. A few instructors I liked were Colt Steele and Brad Traversy.

Alternatively, both Colt Steele and Brad Traversy have Youtube channels that are free and have great content for learning JavaScript. Once you get the hang of the basics, I also recommend The Coding Train, which is run by Daniel Shiffman. I enjoyed all of these instructors’ teaching styles — they have great explanations for different concepts. That said, choose someone who best fits your needs and makes things clearest for you

How to Learn JavaScript Fast

As with any language, learning JavaScript requires time, studying, and practice. I recommend you learn the basics, which include:

  • Variables
  • Types of Data:  Strings, Integers, Objects, Arrays, Boolean, null, and undefined
  • Object Prototypes
  • Loops
  • If Statements/Conditionals
  • Functions

After you have those basics down, hop into some code challenges to get some practice. One site I would recommend is codewars.com. It has tons of challenges with varying levels of difficulty. Start at a basic level. Practice until you are comfortable with the above topics.

Another good practice exercise is making a game like tic-tac-toe or a basic calculator. With these exercises, you will be able to tackle different obstacles and exercise the syntax of JavaScript.

JavaScript Quick Tutorial

Variable Declaration

If the above materials are not enough, here is my quick JavaScript tutorial: 

First, we have variables. In JavaScript, there are three ways you can declare a variable:

  • var: function-scoped.
  • let: block-scoped.
  • const: block-scoped, but cannot be reassigned; it also is initialized with an “a” value, unlike “var” and “let.”

Data Types

There are different data types, as mentioned above, but the most important is Objects. Objects are used for various data structures in JavaScript such as Array, Map, Set, WeakMap, WeakSet, Date, and almost everything made with a new keyword.

A small note about null: If you were to check the data type of null through JavaScript, it would evaluate to an Object. This is a loophole that has been utilized by programmers for years. This might not be very common for you early on…

Comments

Comments in JavaScript are signified with “//” for single-line comments or “/* ….. */” for longer blocks of comments. I bring this up now since the examples below have comments.

Loops

If you are not new to programming, I am sure you know what loops are. For those of you who are new to coding, loops are used to iterate or repeat a block of code a certain amount of times or until a condition is met. Loops are often used to go through items in an Array.

The most common loops are the traditional for loops and while loops. A lot of the following is from the developer.mozilla.org and MDN, which is similar to the documentation for JavaScript — here are some of the different loops JavaScript has to offer:

for loop:

for ([initialExpression]; [conditionExpression]; [incrementExpression]) {

  // statement

}

Provided by MDN:

When a for loop executes, the following occurs:

  1. The initializing expression, initialExpression, if any, is executed. This expression usually initializes one or more loop counters, but the syntax allows an expression of any degree of complexity. This expression can also declare variables.
  2. The conditionExpression expression is evaluated. If the value of conditionExpression is true, the loop statement executes. If the value of the condition is false, the for loop terminates. (If the condition expression is omitted entirely, the condition is assumed to be true.)
  3. The statement executes. To execute multiple statements, use a block statement ({ … }) to group those statements.
  4. If present, the update expression incrementExpression is executed.
  5. Control returns to Step 2.

An actual code example of a for loop:

for (let i = 0; i < array.length; i++) {

 // code here

}

For loops are extremely useful and used often. It is very important to understand and master how for loops work. 

do…while loop:

A do…while loop will run code until a condition is false

do {

  // statement

}

while (condition);

while loop:

A while loop is very similar to the do while loop, but the key difference lies when the conditional is checked. In a do…while loop, the code block runs, and the condition is checked after the while loop checks the condition and runs the block of code.

while (condition) {

  // statement

}

for…in loop:

For…in loop is used to loop over objects

for (variable in object) {

  // statement

}

for…of loop:

For…of loop is used typically for arrays or iterable objects. I must stress using the correct loops for arrays and objects to avoid confusion.

for (variable of array) {

  // statement

}

If Statements

If statements depend on whether a given condition is true and perform what is in the first set of the code block. Do not continue to evaluate the subsequent “else” portions. If there are subsequent conditions that need to be checked, the use of “if else” will be needed. If all conditions do not evaluate as true and there is an “else” provided, the “else” portion of the statement will be used. 

if (condition) {

   // statement1

} else if (condition2) {

   // statement2

} else {

   // statement3

}

Functions

There are two ways to write a function: a function declaration and a function expression. The “return” keyword is used in JavaScript to define what a function will return. All subsequent code below a return statement will not run inside a function.

Function Declaration:

function square(number) {

  return number * number;

}

Function Expression:

var square = function(number) {

  return number * number;

}

The key difference between the two is the function declarations load before any code is executed, while function expressions load only when the interpreter reaches that line of code.

Object Prototype/Classes

In order to provide inheritance, JavaScript utilizes things called prototypes.

Here is an example of what the syntax would look like:

function Person(first, last, age, gender, interests) {

  // property and method definitions

  this.name = {

    'first': first,

    'last' : last

  };

  this.age = age;

  this.gender = gender;

  //...see link in summary above for full definition

}

Creating a new instance of that prototype would look like this:

let person1 = new Person('Bob', 'Smith', 32, 'male', ['music', 'skiing']);

If you come from a different coding language, you may be more familiar with the term “classes.”

JavaScript also has something called classes — classes are built on prototypes:

class Person {

  constructor(first, last, age, gender, interests) {

    this.name = {

      first,

      last

    };

    this.age = age;

    this.gender = gender;

    this.interests = interests;

  }

}

How To Run JavaScript

Since JavaScript is one of the core technologies of the Internet, every modern web browser will have built-in JavaScript consoles. There are also many web-based JavaScript compilers and interpreters.

Browsers

All the big-name browsers such as Chrome, Firefox, Safari, Internet Explorer, and Opera will have JavaScript consoles. I will explain the process on Google Chrome, but all the other browsers can be found in a similar fashion.

In Chrome, right-click anywhere in your browser window and select “Inspect.” Then click on the console tab. From there, you can write “JavaScript” right into the console. Another keyboard shortcut can be found by pressing Command + Shift + J on Mac and Control + Shift + J on Windows.

Web-Based

There are a lot of different web-based JavaScript consoles. My personal favorite is Repl.it, but other options include JS Bin, JSFiddle, and CodePen. Of course, if you find one that you are more comfortable with, you are welcome to use it. 

Can I teach myself JavaScript?

The short answer is yes. I do truly believe you can learn JavaScript on your own, but as with anything, it will take time and discipline. There may be times when you want to quit, think you’ve had enough, or question if you are doing it correctly. My answer to those questions would be to follow the free options of Codecademy and freeCodeCamp (above) as they are very structured and give a good foundation for learning. Never get discouraged; you will be surprised at how much you actually know!

So… should I learn JavaScript or Python?

This is a loaded question and could be a whole article in itself, but it really comes down to use cases. Almost everything outside of the coding languages of JavaScript and Python is alike. This includes popularity, support, community, free and paid courses, and versatile uses.

I mention use cases because if you intend to do web-based programming, you will most likely need to know JavaScript; if you focus on web programming, I would recommend learning JavaScript.

If you are more interested in data analytics, artificial intelligence, and machine learning, Python may be the route to go. This is not to say you can only learn one language. If you are up for it, learn both! Python and JavaScript have evolved a lot since they were created, and both can be used for websites, data analytics, artificial intelligence, and machine learning.

Explore Coding Workshops