fabiochiu/medium-articles huggingface dataset:
10 things to complete your JavaScript skills.
By: M Showkat
Tags: Programming Languages, Programming Tips, Javascript Development, Javascript Tips, JavaScript

1.THIS & GLOBAL THIS:

“This” refers to an example of an object or class. It also changes depending on how a function is called. It’s only relevant wherever you use it and also changes when you are in strict vs. non-strict mode.

2. OBJECTS:

The main reason you must master objects in javascript cause everything in javascript is objects. Object-oriented programming is a must-have skill to claim yourself as a pro.

3.CLASS:

being comfortable with objects, you must start learning the classes which are objects and constructor functions under the hood.

Understanding how an object works, you’ll understand the limitation & advantages of a javascript class. it is a go-to for developers to avoid the cluster of the wired prototype in javascript, and get it done.

4.FUNCTIONS:

After objects, the function is the second most powerful thing in javascript. It is a very important thing to master as a modern javascript developer. it has become a common practice to write functional programming in major frameworks and libraries.

since functional programming is flexible and can be reuse unlimited time, it simplifies the process of writing a complex application much easier. functions in javascript allow you to do anything and can be used in almost all conditions.

5.SCOPE & CLOSURE:

The scope is about making the box and the closure is a special box. If you understand the SCOPE it will help you create code that works together and closure is just a powerful tool you should use if you like the concept of encapsulation and functional programming.

6.DATA STRUCTURES:

You cannot understand how the web work without understanding data structures. it’s a huge topic, but as a developer, this is one of the primary things that you must master.

7.SINGLE THREAD, NON-BLOCKING, ASYNCHRONOUS, CONCURRENT:

these are the core component of web app developments. you will understand better what kind of project should you use javascript by understanding why JavaScript is single-threaded.

8.PROMISE & ASYNC AWAIT:

Promises and async…await allow you to deviate from the traditional linear way to execute programs which for a single-threaded language like Javascript, make it more powerful and fast to compute a lot of things quickly without resourcing to create dedicated threads.

Javascript is a single-threaded language, therefore without creating dedicated threads, it cannot be used for multiple computing and faster processing. so, to avoid that we use promise and async-await.

9.CONTROL FLOW:

If you want to build a complex application, you must understand how things work step by step. it will also allow you to build even more complex programs.

10.FETCH & AJAX:

Since JavaScript mostly use for web-based applications, Data is a huge part of it. You need to send requests, fetch data from the server all the time. so fetch and ajax is something you must understand very well.
Basic JavaScript: Assignment with a Returned Value
By: Châñďăň Ķûmâř
Tags: Javascript Tips, JavaScript, Javascript Frameworks, Javascript Development

If you’ll recall from our discussion of Storing Values with the Assignment Operator, everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.

Assume we have pre-defined a function sum which adds two numbers together, then:

ourSum = sum(5, 12);
JS Shorts — this
By: Prakhar Jaiswal
Tags: Javascript Tips, This, JavaScript, Javascript Development

|warning: this shorts might not be that short :D

this is one of the most confusing concepts of javascript, it behaves a little differently when compared to other languages. The value of this keyword depends on what context (global or object) the function is called.

There are a few rules that must be kept in mind while working with this keyword. The below examples explain the working of this in different scenarios.

Global Context — In global context the value of this keyword refers to the global object ie the window object. Checkout the example below, the output shown here is true

2. Function Context — In case of functions, the value of this keyword depends on how the function is called. Usually in non-strict mode, if the value of this is not set while calling the function, it defaults to global scope. However, we can explicitly set the value for this using function call , bind or apply .

3. Class Context — The behaviour for classes is similar to functions since classes are functions under the hood. The major difference is that classes have their own this object and all the properties of a class are tied to it. All non-static methods within the class are added to the prototype of this.

Similar to functions, we can provide a new context using a new class but that applies only to the unbound methods, the bound methods remain unaffected. Notice below, how a bound method doesn’t get affected.

4. Arrow Function — Finally, if a function is an arrow function it ignores all the above rules and takes the this value from the place where it’s defined.

That was a lot to take and a lot of rules, but that’s how our beloved Javascript is. For an in-depth study refer MDN.

— That’s all for today
What are Generator functions and how to use generator functions
By: Skk Tech-Share, Sai Kumar Korthivada
Tags: ES6, Functions In Javascript, Javascript Development, Javascript Tips, Es6 Features

There are two ways of declaring generator functions

2. Function name prefixed with asterisk(*)

Before going to understand more on generator functions let us try to understand about “yield” keyword of ECMAScript-6

“Yield” Keyword is a new keyword introduced in the ECMAScript -6 which is used to stop the execution inside the Generator function.

“Yield” Keyword can be executed or used only inside the Generator functions and can’t be used inside the general JavaScript functions.

Generator function will always returns the iterator object, when the iterator calls a “next()” method then the function starts execution till the 1st “yield” statement. The “next()” returns an object with two properties i.e…

1. value (any): The value returned by the function till 1st yield statement.

2. Done (Boolean value): Returns a boolean value true or false which defines whether the function execution is completed or not.
JAVASCRIPT | ABORTA!
By: Fernando Bernal
Tags: Javascript Tips, JavaScript, Javascript Development, Fetch Api

Computer engineer with over 10 years of experience.
JS Shorts — Bind
By: Prakhar Jaiswal
Tags: Bind, JavaScript, Javascript Development, Javascript Tips

The bind() method creates a new function that, when called, has its this keyword set to the provided value followed by the arguments of the function.

In simple words, if we want to provide a value for this keyword to any function tied to an object or a class, we use bind() . If these functions are called without binding them to a scope, they would be called in a global context, ie the window object.

Syntax:

let boundFunc = func.bind(thisArg[, arg1[, arg2[, ...argN]]])

Consider the below snippet,

The above code produces undefined as an output. This is because setTimeout receives person.getName as a callback function. The callback is executed in a global scope after the timeout hence the value of this.name is missing.

One way to fix this problem is to pass in a separate function as a callback and invoke person.getName() inside it, so that the getName function is called with person as a scope.

The other way to fix this problem is to simply use bind with getName and assign the person scope to it.

Both these approaches work because we are providing a scope to the getName function. Both of these snippets produce John Doe as an output.

This was function bind in its most basic form. We can also use this to invoke methods of one object with other simply by binding it.

Image by Pexels from Pixabay

— That’s all for today
Mom, I want to be frontend
By: Gerardo Fernández
Tags: Frontend Development, Javascript Development, JavaScript, Frontend, Front End Development

A few years ago, web development was finally divided into backend and frontend. Since then, the evolution of front development has been spectacular. In fact, I would dare to say that progress has been much greater in this specialty. In addition, every so often we witness the appearance of new libraries, frameworks and functionalities that push this world a little further. What used to be limited to HTML, CSS and a bit of Javascript is now a conglomerate of concepts and technologies that must be followed carefully so as not to be left too far behind.

The other day they asked me if I saw sense in the figure of the layout designer in 2020 and, unfortunately, I answered no. Right now I find it very difficult to imagine front development without Javascript. In fact I go further: I would say that it is not enough just to know this language and master some of its frameworks / libraries, but to be more and more complete we need to know a few more things.

Let’s see them!
Kenapa Peminat JavaScript Developer Semakin Banyak? Ini Alasannya!
Tags: Mobile App Development, Indonesia, Javascript Development, Website, Developer

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
JavaScript Console commands other than console.log()
By: Sanchitha Sr
Tags: Web Development, Programming, Coding, Javascript Development, Javascript Tips

console.error() — Sends message to the console window. The message text is red and prefaced by an error symbol.

2. console.warn() — Sends message to the console window, prefaced by a warning symbol.

3. console.table() — Displays the JSON / Array in table format which is easier to read.

4. console.group() and console.groupEnd() — console.group() and console.groupEnd() are used to group the messages.

NOTE: The console.groupCollapsed( ) can be used instead of console.group() to make it appear in a collapsed view by default.

5. console.dir() — It displays the JSON in an object visualizer. Makes it easier to inspect properties in the console window.

6. console.assert(expression, message)—Sends a message to the console window if expression evaluates to false.

7. console.time(‘name’) and console.timeEnd(‘name’) — These are used to track time of the codes between them to get executed. It calculates the time that elapses between time and timeEnd , and sends the result (measured in ms) to the console using the name string as a prefix.

8. console.clear() — This command is used to clear the console messages. Just run this command and your console will be clear as new.

And that sums it up..

Thank you
How do I test for an empty JavaScript object?
By: Pink Academy
Tags: Web Development, Javascript Development, Javascript Tips, JavaScript, Front End Development

In this short tutorial we are going to explore some options and examples for testing Javascript objects for the empty condition.

There are times when working with objects the returned object will come as:

var object= {};

This could happen when working with modules that pass data from a server to server, it might be the response of an API or backend service etc, so it’s handy to know in which way Javascript can check if object is empty.

Checking for empty objects in Javascript is easy, let’s jump into it.
5 Top Reasons Why You Should Learn JavaScript in 2020
By: Siwar Hkimi
Tags: Web Development, Javascript Development, Javascript Tips, Development, JavaScript

No one can deny that today the whole world is going toward digitalization especially after the COVID-19 crisis. This fact yields automatically to the increased demand in the tech field, in particular, web development.

In this context, the question always comes to which programming language is better? Here are the 5 top reasons why JavaScript is perfect to learn in 2020.

Photo by Nathan da Silva on Unsplash

1. JavaScript is beginner-friendly

Due to the simple syntax that JavaScript uses, it is considered one of the easiest languages to learn, unlike C++, C#, Java, etc,...

For example, to print a text you need only to use the console.log() method instead of weird and complex syntax in other languages. You can see the difference between printing a simple text in C++, Java, and JavaScript in the following images :

Hello World in C++

Hello World in Java

Hello World in JavaScript

As you can see JavaScript not only uses simple words but also saves you some lines of code.

2. It is Free to use

To run JavaScript code, you only need your browser to begin or a simple text editor like VSCode to write projects. You don’t need to buy any license like for example MatLab, SAS, SPSS, …

Besides, in your journey of learning, you will find tons of free sources such as articles, websites, Youtube channels, which provide you with well-structured context, courses, and exercises.

3. It has a large community

If in case you got stuck or you have some bugs in your code and you don’t know what to do, just go to Google and type in your question, 90% of the time you will find another person went through the same issue before you and you will find many developers who answered him. Just read the answers and try to figure it out.

Otherwise, you can publish your question on StackOverflow (a platform for developers where they can learn, share their knowledge, collaborate, and build their careers) or on any similar website and you will find big support from the community.

4. It is highly in demand and well paid

In this section, I will let the numbers speak for themselves.

According to DevSkiller, JavaScript is the most in-demand IT skill of 2020.

According to Glassdoor, the average salary of a JavaScript developer is $79,137 per year in 2020.

5. It is versatile

This is my favorite point. With JavaScript, you can do multiple exciting things. You can for example become a front-end developer, back-end developer, or best of all a full-stack developer.

Besides web development, you can also make mobile apps using frameworks built on JavaScript like React Native, Ionic, AngularJS, to name a few.

Also, you can build desktop applications using Electron, NodeGUI, NW.js,…

If you are interested in learning artificial intelligence, you can do it with TensorFlow.js, Brain.js, Deeplearn.js, and many other libraries.

And the list goes on.
Have you heard currying function? What is it?
Tags: Web Development, Javascript Frameworks, Javascript Development, Development, JavaScript

A currying function is a function that takes various arguments and transforms it into an arrangement of function having just a single argument at a time.

Along these lines, a n-ary work turns into an unary function, and the last function return the aftereffect of the apparent multitude of arguments together in a function.

Currying function we use almost but weren’t aware about it’s called currying function.
Make your Confusion clear in JS
By: Kuntal Ghosh
Tags: Javascript Tips, Js, JavaScript, Javascript Development

Truthy and Falsy

With type, every value has a boolean value called truthy or falsy value.

The following values are always falsy:

false

0 (zero)

(zero) '' or "" (empty string)

or (empty string) null

undefined

NaN

Everything else is truthy. That includes:

'0' (a string containing a single zero)

(a string containing a single zero) 'false' (a string containing the text “false”)

(a string containing the text “false”) [] (an empty array)

(an empty array) {} (an empty object)

(an empty object) function(){} (an “empty” function)

double equal (==) vs triple equal (===)

Loose Equality Comparisons With( ==)only compares 2 values not the types of the values

2==”2”// returns true

Strict Equality Comparisons With (===) compares 2 values with their type.

2==”2”// returns false
Call back function
By: Shakil Mahammud
Tags: Callback Function, Js, Shakil, Javascript Development, JavaScript

A call back function is a function it can be any function anonymous Function, arrow function. passed into another function as an argument,

Ex:

function callBackFuncArray(array, callback) {

array.push(50);

callback()

}

const array=[2,4,6,8,10]

callBackFuncArray(array, function() {

console.log(‘its a call back function example’, array)

}) ;
SOLID principle #5: Dependency Inversion (JavaScript)
By: Duncan Mcardle
Tags: Solid Principles, Solid, Javascript Development, JavaScript, Software Development

Note: This post is part of a series of posts on the SOLID principles for software development (specifically in JavaScript). You can find them all at the following links:

1. Single responsibility

2. Open-closed

3. Liskov substitution

4. Interface segregation

5. Dependency inversion

The dependency injection principle states that high level code should never depend on low level interfaces, and should instead use abstractions. It’s all about decoupling code.

Not following? I don’t blame you, but it’s surprisingly simple.

Let’s say we have a piece of software that runs an online store, and within that software one of the classes ( PurchaseHandler ) handles the final purchase. This class is capable of charging the user’s credit card, and does so by using a PayPal API:

The problem here is that if we change from PayPal to Square (another payment processor) in 6 months time, this code breaks. We need to go back and swap out our PayPal API calls for Square API calls. But in addition, what if the Square API wants different types of data? Or perhaps it wants us to “stage” a payment first, and then to process it once staging has completed?

That’s bad, and so we need to abstract the functionality out instead.

Rather than directly call the PayPal API from our payment page, we’ll instead create another class called PaymentHandler . The interface for this class will remain the same no matter what underlying payment system we use, even if the two systems are completely different. We’ll still need to make changes to the PaymentHandler interface if we change payment processor, but our higher level interface remains unchanged.

Now you may be looking at this and thinking “but wait, that’s way more code”, and you’d be right. Like many of the SOLID principles (and indeed OO principles in general), the objective is less about writing less code or writing it quicker, and more about writing better code. The above change will save you days or maybe even weeks further down the line, in exchange for spending a few hours on it now.
Hacker Rank- Day 8th Challenge solved in javascript- Dictionaries and Maps
Tags: Hackerrank, Hackerrank Solution, Javascript Development, Javascript Tips, JavaScript

function processData(input) { let phoneBook = new Map(); let arr = input.split('

'); let stringValue = ''; for(var i=1; i<arr.length; i++){ let valueSplit = arr[i].split(' '); if(valueSplit.length>1){ phoneBook.set(valueSplit[0], valueSplit[1]) } else{ if(phoneBook.has(valueSplit[0])){ stringValue += valueSplit[0]+'='+phoneBook.get(valueSplit[0])+'

'; } else{ stringValue += 'Not found'+'

'; } } } return stringValue; }

I hope you can find your way with this solution!

Happy Coding!
SOLID principle #2: Open-Closed (JavaScript)
By: Duncan Mcardle
Tags: Solid Principles, Javascript Development, JavaScript, Solid, Software Development

Note: This post is part of a series of posts on the SOLID principles for software development (specifically in JavaScript). You can find them all at the following links:

1. Single responsibility

2. Open-closed

3. Liskov substitution

4. Interface segregation

5. Dependency inversion

The open-closed principle says that code should be open for extension, but closed for modification. What this means is that if we want to add additional functionality, we should be able to do so simply by extending the original functionality, without the need to modify it.

To explain this, let’s look at an example. Below we have a Vehicle class. When a Vehicle instance is created, we pass in the fuel capacity and fuel efficiency. To get our range, we simply multiply our capacity by our efficiency.

But let’s say we add a new type of vehicle; a hybrid vehicle. This vehicle doesn’t just have standard fuel-based range, it also has an electric range which it can use as well. To find out the range now, we need to modify our getRange() method to check if the vehicle is hybrid, and add its electric range if so:

This violates the open-closed principle, because whilst adding our new HybridVehicle class we have had to go back and modify the code of our Vehicle class in order to make it work. Going forward, every time we add a new type of vehicle that might have different parameters for its range, we’ll have to continually modify that existing getRange function.
SOLID principle #1: Single responsibility (JavaScript)
By: Duncan Mcardle
Tags: Solid Principles, Solid, Javascript Development, JavaScript, Software Development

Note: This post is part of a series of posts on the SOLID principles for software development (specifically in JavaScript). You can find them all at the following links:

1. Single responsibility

2. Open-closed

3. Liskov substitution

4. Interface segregation

5. Dependency inversion

The single responsibility principle says that a class or module should have only a single purpose. For example, if you have a wallet class, that class should only implement wallet functionality. It’s fine to call other functionality, but it shouldn’t be written there.

Let’s look at a bad example. In the code below, the Car class has a single method; start. When this method is called the car may or may not start, depending on some logic which isn’t included here as it’s not important. The class will then log some information depending on the outcome. But notice how the logging functionality is implemented as a method of this class:

This violates the single responsibility principle, because the logic for logging the information should not be a responsibility of the Car class.

There are a number of readability and code management issues that are caused by this, but the easiest issue to describe is actually refactoring.

Let’s say your logger logs to a file, and this works great for several months. Suddenly, an update occurs on the underlying system that the car class is running on, and you need to change the way you write to files. Suddenly you now need to update every file writing instance of every class you’ve ever implemented a logger inside of. The task would be huge! But what if you’d followed the single responsibility principle?

As you can see here, we wouldn’t have this problem. The logger is stored in a separate class, which means its functionality is separate to the Car class. The Car class can be changed, moved around or even deleted without affecting the logger class. Likewise, if a change is required to the logger class, it only needs to be carried out in a single place.
SOLID principle #3: Liskov Substitution (JavaScript)
By: Duncan Mcardle
Tags: Solid Principles, Javascript Development, JavaScript, Solid, Software Development

Note: This post is part of a series of posts on the SOLID principles for software development (specifically in JavaScript). You can find them all at the following links:

1. Single responsibility

2. Open-closed

3. Liskov substitution

4. Interface segregation

5. Dependency inversion

The Liskov substitution principle states that any class should be substitutable for its parent class without unexpected consequences. In others words, if the classes Cat and Dog extend the class Animal, then we would expect all of the functionality held within the Animal class to behave normally for a Cat and Dog object.

A classic example of a Liskov substitution violation is the “square & rectangle problem”. In this problem, it is posed that a Square class can inherit from a Rectangle class. On the face of it, this makes sense; both shapes have two sides, and both calculate their area by multiplying their sides by each other.

But the problem arises when we try to utilise some Rectangle functionality on a Square object. Let’s look at an example:

In this example we initialise a Rectangle and Square , and output their dimensions. We then call the Rectangle.setHeight() on the Square object, and output its dimensions again. What we find is that the square now has a different height than its length, which of course makes for an invalid square.
SOLID principle #4: Interface Segregation (JavaScript)
By: Duncan Mcardle
Tags: Solid Principles, Javascript Development, JavaScript, Solid, Software Development

Note: This post is part of a series of posts on the SOLID principles for software development (specifically in JavaScript). You can find them all at the following links:

1. Single responsibility

2. Open-closed

3. Liskov substitution

4. Interface segregation

5. Dependency inversion

The interface segregation principle states that an entity should never be forced to implement an interface that contains elements which it will never use. For example, a Penguin should never be forced to implement a Bird interface if that Bird interface includes functionality relating to flying, as penguins (spoiler alert) cannot fly.

Now, this functionality is a little more difficult to demonstrate using JavaScript, due to its lack of interfaces. However, we can demonstrate it by using composition.

Composition is a subject all by itself, but I’ll give a very high level introduction: Instead of inheriting an entire class, we can instead add chunks of functionality to a class. Here’s an example that actually addresses the interface segregation principle:

What this example does is to add the flying functionality (or interface) only to the class(es) that require it. This means that penguins won’t be given the ability to fly, whereas birds will.

This is one method of adhering to the interface segregation principle, but it is a fairly rough example (as, once again, JavaScript doesn’t play well with interfaces).
JS Operator
By: Onur Dayıbaşı
Tags: Operators, JavaScript, Javascript Development, Front End Development

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Boost Jetpack Day-3
By: Arman Hossen
Tags: Javascript Tips, JavaScript, Javascript Development

React is a Framework or library?

Actually in we face lots confusions in the beginning is it framework or library?.to answer this question first we have to understand what is framework and what is library.

Framework means who gives already made smart designs of code which is good for young startups but it won't be good for experienced developers who works on large code bases.

Library means collection of lots of functions that can be use for web pages. We just take those functions from the library and implement them in our web pages.

So the answer is a React is a Library

Dom

Dom means “Document Object Model”. It is the thing we in web pages. We can change anything in a web document using DOM API. We can change and manipulate HTML from the website. And In DOM everything structures as tree

Why React Gained Most Popularity

In previous days it was hard to work with DOM. But when it comes with React instead of working DOM we work with ‘virtual’ React. So we assign work to React then React does that work with Dom.

JSX is not HTML

In React JSX is not Html. JSX is just a syntactic sugar of html , It is also JavaScript. When we type JSX what it actually does in back hood is it calls a function React.createElement and this function communicated with DOM.

How to use JavaScript expressions inside JSX

In JSX you can also write JavaScript expressions with a pair of curly braces but you can only include expressions . You can use regular if else statement into JSX but ternary is okay to write.

Virtual Dom

Virtual DOM is a like a programming concept that runs in the back hood. So when we change something from code it actually compares virtual DOM with real DOM and update whatever have been changed.

React Component

In react components can be created with classes or functions. A component creates by extending React. Component class. In class base components you must have to define another subclass called render() . But in functional component you can just return your codes.

Default Props In React

In react if some props have sent then we have to get it. Suppose there is a option props that needs to be pass. But we want that if props have not passed than it will a default value by itself. As an example if ‘name: arman’ is need to pass as props but name props have not sent it will automatically take default value ‘Hussain’

React App Deploy

When we create a React we just run ‘create react-app app’ and then we implement our React app and make functionalities in our React app but when it comes to deploy the React app in server there are several steps that we have to take care. So after finishing your project you have to type “NPM run build” then react will automatically build your app and you can just upload your build file in your website.

IN React All is JavaScript

In react app you all the things are JavaScript. JSX functions classes everything is JavaScript. So what react does is we tell react to do some work and react communicates with DOM and print according to our command
Some Problem Solving in JavaScript.
By: Md Rashidul Islam
Tags: Js, JavaScript, Javascript Development

Cover Photo

JavaScript variable : JavaScript more then used variable like var, let, const etc. variable name declarer also time first letter used is lowercase , and more then used declarer variable name letter +digit or lowercase + some uppercase latter.

Foot to Inch: We know 1 foot = 12 inch. When we are convert foot to inch . Then we are apply foot * inch. like 1*12. and inch to foot foot/inch like 120/12.

foot to inch and inch to foot

Some information coming soon…….
LeetCode problem #25–Reverse nodes in k-group (JavaScript)
By: Duncan Mcardle
Tags: Leetcode Hard, Leetcode Solution, Javascript Development, Leetcode, JavaScript

In this LeetCode challenge, we’re asked to reverse the elements of a LinkedList, in a very similar way to in the previous challenge. What’s different this time however, is that the number of nodes in each batch to be reversed is determined at run-time, instead of being a standard 2.

To give an example, given a LinkedList with values of [1, 2, 3, 4, 5, 6] , we previously reversed all pairs to get [2, 1, 4, 3, 6, 5] . Now however, we might be passed reverse-group-size value (k) of 3, which would cause the LinkedList to become [3, 2, 1, 6, 5, 4] , or 4, which would create [4, 3, 2, 1, 5, 6] (because there aren’t enough nodes to reverse the 2nd set of 4 nodes).

To help understand the below solutions, we will split this problem into two parts.

The first part is to identify blocks of ListNodes that need reversing. If we have 5 nodes in our LinkedList, and have been given a k value of 2, then we know we can reverse the nodes [1, 2] (to get [2, 1] ), and [3, 4] (to get [4, 3] ), but 5 will be left as is, giving us a final output of [2, 1, 4, 3, 5] . Likewise, if we’re given a k of 4, then we must reverse [1, 2, 3, 4] (to get [4, 3, 2, 1] ) but do not have enough nodes for a second batch of reversal, so we’re left with [4, 3, 2, 1, 5] .

The second part is the actual reversal. In order to reverse a LinkedList, we’ll need to point each ListNode to its predecessor, and then point the final node to the node that follows. Back To Back SWE did a great video on this that I’d recommend watching, as its a difficult concept to explain here.

Solution #1: Recursive

LeetCode user schpolsky posted this very elegant recursive solution to the problem. In it, we reverse the first k elements of the passed in LinkedList, and call the function again on the rest of the LinkedList. If the rest of the LinkedList is k or more elements long, another reversal is carried out on that segment, and the process continues. If not, the last part of the LinkedList is returning in its original order, and the overall LinkedList is then returned.

Solution #2: Iterative

LeetCode user ofLucas posted this great iterative solution (ironically enough, n the comments to the other recursive solution!). It first establishes the total length of the LinkedList, and then loops through the initial LinkedList, keeping track of the starting point of the current batch of k nodes, and then reverses them if it reaches k nodes in size. This process repeats until the loop runs out of elements, by which point we have reversed every batch of k nodes in the LinkedList.
Generator Function และ yield ใน JavaScript
By: Teeraphong Chaichalermpreecha
Tags: Generator Function, Functional Programming, Javascript Development, Yield, JavaScript

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
LeetCode problem #23–Merge k sorted lists (JavaScript)
By: Duncan Mcardle
Tags: Leetcode Hard, Leetcode Solution, Javascript Development, Leetcode, JavaScript

In this LeetCode challenge, we’re given an array of LinkedList elemenets, and asked to return a single LinkedList, containing all of the ListNodes contained within the supplied LinkedList elements, ordered. In other words, we must merge all of the LinkedList objects together, and then sort them.

For most of these solutions, we’ll be using the recursion based LinkedList merger that we created for LeetCode challenge 21, “Merge two sorted lists”.

Solution #1: Merging all LinkedList objects into the first

This solution is probably the easiest to understand, but also the least efficient. Armed with our merge function, it’s fairly trivial to simply loop through all of the provided LinkedList elements, and merge their contents into the first LinkedList. The merging function takes care of sorting, so we’re left with a fully merged, ordered LinkedList.

The problem with this solution is efficiency. Because our merge operation is constantly being carried out on the ever-growing first LinkedList, it’s getting bigger and bigger each time. It would be much more efficient to merge smaller LinkedList elements together, and then to merge their outputs together and so on, so that’s exactly what we’ll look at next.

Solution #2: Recursive merging

In this solution, we pass a recursive function our array of LinkedList objects. That function then calculates the middle point, and calls itself again on both the left and middle, and the right + 1 and middle, or if there are insufficient LinkedLists remaining, it simply returns what it was given.

What this means is that we end up calling the function on every pair of LinkedLists, merging them together as we go. Therefore by the time the recursive function has worked its way back all the way to the top, we’re left with a single ordered LinkedList.

To use an example, let’s say we have 3 LinkedLists. We pass the function those lists, and it creates 2 merge-pairs; 1 + 2, and 3 + nothing. It then merges 1 with 2, and 3 with nothing, then it steps back and merges the combined 1+2 with 3+nothing, giving us a single, ordered LinkedList.

Solution #3: Convert to an array

I’ll admit that this method is somewhat of a cheat, but it does work, and it works quickly too. What we do here is we traverse every provided LinkedList, adding their values to an overall array. We then order that array, and convert it to a new LinkedList.

Note that the way we convert the array to a LinkedList is to do it in reverse order. This is because it allows us to create the last ListNode, which points to nothing, and then to create the second-to-last ListNode, which points to the last, and then the third-to-last ListNode, which points to the second-to-last, and then… well you get the idea.
LeetCode problem #24–Swap nodes in pairs (JavaScript)
By: Duncan Mcardle
Tags: Leetcode Medium, Leetcode Solution, Javascript Development, Leetcode, JavaScript

In this LeetCode challenge, we’re asked to create a function that takes a LinkedList and swaps each of its ListNode elements in pairs. In other words, if the LinkedList’s values start as [1, 2, 3, 4] our function should change it to [2, 1, 4, 3] .

The reason this challenge isn’t incredibly easy is because of the way in which we swap ListNodes. Unlike arrays, ListNodes require updating once swapped, to ensure that their .next pointers are correct. What this mans is that in order to swap 2 ListNodes, the following must take place (note that when I say “point” in these instructions, I am referring to that node’s .next value):

The node before the nodes being swapped must point to node 2 Node 2 must now point to node 1 Node 1 must now point to node 3

For both of the below solutions, we initialise a “dummy” list, which is a copy of the original LinkedList, with a dummy node added to its head. This allows us to manipulate what was originally the first ListNode easily, and we can then chop off this dummy node at the end by returning the dummy LinkedList’s .next property.

Solution #1: While loop

In this solution, we initialise a copy of the original LinkedList which we will use to traverse it, swapping as we go. We then run a while loop for so long as there remain 2 or more elements in the new LinkedList, as 2 are required in order to perform a swap.

Finally, we swap the 2 nodes, traverse 2 nodes further into the LinkedList, and the process repeats.

Solution #2: Recursive

This approach is more or less identical to the while loop, but is slightly more concise. The performance differences between the two approaches in JavaScript are negligible.
LeetCode problem #19–Remove nth node from end of list (JavaScript)
By: Duncan Mcardle
Tags: Leetcode Medium, Leetcode Solution, Javascript Development, Leetcode, JavaScript

In this LeetCode challenge, we’re given a LinkedList, and asked to remove the nth-from-last node (where n is supplied, alongside the LinkedList, to our function).

The biggest issue here is that we don’t know the length of the LinkedList, so finding length — n is currently impossible. This means our first course of action is to find the length, so that we can find length-n , and then remove that node.

Note #1: With the provided implementation, you cannot delete a ListNode as such. What you must do instead is to point the ListNode that comes before it, to the ListNode that comes after it (or to null if there is no ListNode after it). This effectively deletes the target node.

Note #2: Both of the below solutions create a dummy ListNode entry at the start of the LinkedList. This is because it allows us to easily skip over the first node in the list with the same logic as we use elsewhere. Otherwise, we would have to use eparate logic to handle cases where the first node in the LinkedList is the one being removed, which would complicate and expand the code.

Solution #1: Double loop

This solution does what probably came to your mind first. To begin with, we traverse the LinkedList until we reach its end, which gives us the length of the LinkedList. Then, we traverse it once more, this time stopping when we get to the node right before our target node. Finally, we point the next value of the node before our target one, to the node after our target one, effectively removing our target node from the list.

Solution #2: Single loop

One of the potential complexities listed on the page for this problem is to find a way to do this with one loop, so here’s how.

We start by initialising two pointers; a fast and a slow. We then move the fast into the LinkedList n times. Next, we move both pointers forwards into the list until the fast pointer reaches the end. By doing this, we have effectively moved the slow pointer to length-n without ever knowing what the length of the LinkedList actually was, and by using only a single full loop (split into 2 partial loops).

From here we can apply the same logic as before, by pointing the element preceding our target one to the one that follows it, effectively deleting our target element out of the LinkedList.
Açık Bankacılık Uygulamaları: Portekiz
By: Zeynel Enes Mi̇rza
Tags: Açıkbankacılık, Portekiz, API, Türkçe, Bankacılık

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Ototelik Deneyimler Bize Ne Sunuyor
By: Levent Özkuşcu
Tags: Felsefe, Psikoloji, Türkçe, İnsan, Akış

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
2021'in En Önemli Hedefi
By: Ümit Uzun
Tags: Bağımlılık, Sigara, Türkçe, Sağlık, Pandemi

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Suya Kapılanlar
By: Ercan Akıncı
Tags: Türkçe

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Rusya’nın Şeytanı: Grigory Rasputin
By: Enes Talha Elbüz
Tags: Rasputin, Romanov, Rusya, Türkçe

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Mesleklerin Geleceği Hakkında Bilinmesi Gereken 5 Şey
Tags: Rapor, Türkçe, Meslek, Gelecek, Covid 19

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Miami’de Neler Oluyor?
By: Uluc Aydemir
Tags: Girişimcilik, Silikon Vadisi, Miami, Türkçe, Yatırım

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Web Sitenizi Geliştirmek İçin Ücretsiz SEO Araçları
By: Mevlüt Bingöl
Tags: Web Site Trafiği, Pazarlama, Dijital Pazarlama, Türkçe, SEO

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Hayat Bir Yerlere Sığar (mı?)
Tags: Türkçe

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
2020 Defteri Kapanırken
By: Ece Güney
Tags: Médium, Türkçe, Kişisel Gelişim, Türkçe Yayın, Yeni Yıl

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Mimarlık ve Müzik
By: M. Furkan Bakar
Tags: Türkçe, Türkçe Yayın, Mimarlık

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
20. Yüzyıl Müziği — Tango X.T.C, Joe Hisaishi
Tags: Tango Xtc, Hayao Miyazaki, Joe Hisaishi, Türkçe, Film Müzikleri

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Sevdiğimiz Kitaplardan Alıntılar #2: Oblomov
By: Botan Orak
Tags: Oblomov, Gonçarov, Türkçe, Alıntı, Edebiyat

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Pandemi’de İş Değişikliği Yapmak
By: Ömer Kılıçaslan
Tags: Home Office, Türkçe, Türkçe Yayın, İşletme

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
İbni Asâkir Kimdir?
Tags: Şam, Tarihi Medineti Dımaşk, Tarih, Türkçe, İbni Asakir

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Kambur Güzelin Hikayesi
By: Hamuş Melike
Tags: Kadın, Hikaye, Türkçe, Engelli, Köy

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore