teleren/devto huggingface dataset:
A Practical Introduction to Closures in JavaScript
Tags: javascript, closures
Published: 2024-04-05 23:06:33

---
title: A Practical Introduction to Closures in JavaScript
published: true
description: Closures are a very interesting topic, and it is a demonstration of how to leverage the lexical scope in JavaScript
tags: JavaScript, Closures
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sss8w89m1o0vrbkpn8o.png
# Use a ratio of 100:42 for best results.
# published_at: 2024-04-05 21:49 +0000
---

Closures are a very interesting topic, and it is a demonstration of how to leverage the lexical scope in JavaScript.

Let's start by showing a code example first:

```javascript
function outerFunction() {
  let count = 0;

  return function innerFunction() {
   count += 1;
   console.log(`Count is now ${count}`)
  }
}
```

Before adding more code, I think it is important to mention that when a function is invoked, after doing its stuff and returning its output, all the variables and functions and any data inside that function will be completely gone.

So, one might think that, if that's the case, the count variable will dissapear right after `outerFunction` is invoked, and the returned function will lose access to the count variable.

But, due to the lexical nature of JavaScript, when a function is created, like `innerFunction` in this case, it will always be returned along with its scope.

Even after the `outerFunction` has finished executing, the `innerFunction` retains access to the variables in its outer scope, allowing it to keep data private and alive throughout the lifecycle of the application.

Let's continue with our example above:

```javascript
function outerFunction() {
  let count = 0;

  return function innerFunction() {
   count += 1;
   console.log(`Count is now ${count}`)
  }
}

const myFunction = outerFunction() // outerFunction is executed and, and myFunction becomes innerFunction

myFunction() // Count is now 1
myFunction() // Count is now 2
myFunction() // Count is now 3
```


So basically functions can carry with them the scope in which they were created. This includes any variables or fucntions that were in scope at the time of creation. 

So as you can see, when we return `innerFunction` from `outerFunction`, we're not just returning the `innerFunction` code, we're returning a package of the function and its scope, and this scope that gets returned along with the function, and to which the function keeps access to, is what we call a closure. 

Long story short: in JavaScript, a closure is created every time a function is created.


##Comming soon...

I will continue expanding on this topic soon, by deepen the discussion on lexical scoping and practical applications like memoization.
Unity Dev Blog #5
Published: 2024-04-05 22:13:35

I took a break for 2 days after being stuck for 2 days on Menus. Menus and Scenes are definitely a weak point of mine and I've been avoiding them which has come back to bite me. I had created a Main menu and a GameOver menu, it took a while to work out how to load and unload them and then I got stuck on the GameOver menu not being interactable at all. I looked all over the internet and nothing helped.

After 2 days off the project I finally figured out the issue. The GameOver menu had 2 canvases, I assume one was blocking the other. Removing it has fixed the issue but I still have some wiring to do. 

I think next project I'll start with the menus, they are a pain and not that fun.

I next want to work on on hit effects, death animations and upgrades - more fun stuff.
My projects
Published: 2024-04-05 22:03:10

Book appointments with WhatsApp and sms [Rezque](https://rezque.com)
Custom projects like stripe license manager and email parsers [Boopis](https://boopis.com)
Get UTM params in your CRM! [Attribution](https://attribut.io)
[License Manager for Stripe](https://keystor.app)
[Email Extractor for Gmail and Google Sheets](https://xtractor.app)
[Email Parser for Gmail and Google Sheets](https://workspace.google.com/u/2/marketplace/app/email_parser/40769086099)
Techie success story
Published: 2024-04-05 21:53:35

when people are posting their success stories they don't say the back end, the struggles, the thousands of turned down offers... landing a job as a junior uiux designer is frustrating, speaking out of experience, wait till now I'm unemployed. it feels right to say money is the king of all motivation💵, you can't call yourself the best if you are not making money of your skill🥺... Now were do we find junior uiux design jobs, instead of introducing us to different platforms where don't don't even check out your resume or portfolio before turning you down. I'm saying this with pain and sincerity what does it take to know ones future in tech 🥺
5 Open-Source Next.js Projects Rocking 2024 (Learn the Patterns!) 🚀
Tags: javascript, nextjs, typescript, beginners
Published: 2024-04-05 21:37:57

If you are a Junior or still learning to write code, it is best if you see others code, which is concidered one of the harder things. Definitely harder docs and indeed harder than building things (which you can copy/paste and GPT your way around it) but needed experience to understand what others push to production.

And what would be better than seeing code of apps in production, let alone these apps are make Huge MRRs! So [we](https://evotik.com) choose here 5 next.js project for you that are open source AND in production. Take the time to review them, understand the patterns, how these apps deal with different problems, what are they using under the hood to tackle different issues and needs of being great user apps.

## Typebot

[Typebot](https://typebot.io/) is an Open-Source Chatbot Builder for Streamlined User Engagement

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlq209oc6rtfqt0x5ynp.png)

Developers love Typebot, an open-source chatbot builder that empowers anyone to create advanced chatbots visually.  No coding required!  Embed these chatbots directly into web or mobile apps to collect real-time results and continuously improve user interactions.

[Github Repository: Here](https://github.com/baptisteArno/typebot.io)

## Dub

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjne9oldvtnjt2l7ksyx.png)

[Dub](https://dub.co/) Open-source link management. Create, share, and track short links for streamlined marketing campaigns.

[Github Repository: Here](https://github.com/dubinc/dub)

## OpenStatus

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6n1decszkl5w9ioyortp.png)


[OpenStatus](https://www.openstatus.dev/) platform provides comprehensive monitoring capabilities with a visually appealing status page. Users can choose to self-host the software for complete control or utilize the hosted version for a more convenient setup.

[Github Repository: Here](https://github.com/openstatusHQ/openstatus)

## Formbricks

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1oq3waci9jtxgtx9zmp7.png)

[Formbricks](https://formbricks.com/) is a solution for micro-surveys that will supercharge product experience with in app integration. 

[Github Repository: Here](https://github.com/formbricks/formbricks)


Disclaimer: No affiliate links there 😁.

Checkout other articles

- [8 NPM Packages for JavaScript Beginners [2024]](https://dev.to/evotik/8-npm-packages-for-javascript-beginners-2024tutorials-5f85)
- [Nuxt vs Next | Biased Opinion](https://dev.to/evotik/nuxt-vs-next-biased-opinion-4iei)
- [NodeJS 22 is Out and Live](https://dev.to/evotik/release-of-nodejs-22-live-what-is-new-100f)
Salesforce Apex XIRR Excel function
Published: 2024-04-05 21:06:01

If you're looking to integrate the XIRR Excel function into your Salesforce Organization, I'd like to offer you this Apex code. It produces results identical to the Google Spreadsheet XIRR function.

The XIRR method calculates the internal rate of return for a schedule of cash flows, even when they are not necessarily periodic.

https://github.com/stonarelli/stonarelli/tree/master/XIRR/Salesforce/src/classes

ALso you can find test examples

Regards!
Arquitectura limpia en proyecto de Nodejs + Typescript + MongoDB
Tags: node, typescript, mongodb, backend
Published: 2024-04-05 20:55:51

**Estructura**

├── api
│   ├─── controllers
│   │   ├─── usuarios.controller.ts
│   │   ├─── publicaciones.controller.ts
│   │   ├─── seguidores.controller.ts
│   │   ├─── ...
│   ├─── middlewares
│   │   ├─── auth.middleware.ts
│   │   ├─── error.middleware.ts
│   │   ├─── ...
│   ├─── routes
│   │   ├─── usuarios.routes.ts
│   │   ├─── publicaciones.routes.ts
│   │   ├─── seguidores.routes.ts
│   │   ├─── ...
│   ├─── services
│   │   ├─── usuarios.service.ts
│   │   ├─── publicaciones.service.ts
│   │   ├─── seguidores.service.ts
│   │   ├─── ...
│   ├─── utils
│   │   ├─── utils.ts
│   ├─── index.ts
├── application
│   ├─── config
│   │   ├─── app.config.ts
│   │   ├─── database.config.ts
│   │   ├─── ...
│   ├─── models
│   │   ├─── usuario.model.ts
│   │   ├─── publicacion.model.ts
│   │   ├─── seguidor.model.ts
│   │   ├─── ...
│   ├─── repositories
│   │   ├─── usuarios.repository.ts
│   │   ├─── publicaciones.repository.ts
│   │   ├─── seguidores.repository.ts
│   │   ├─── ...
│   ├─── services
│   │   ├─── usuarios.service.ts
│   │   ├─── publicaciones.service.ts
│   │   ├─── seguidores.service.ts
│   │   ├─── ...
│   ├─── utils
│   │   ├─── utils.ts
│   ├─── index.ts
├── domain
│   ├─── entities
│   │   ├─── usuario.entity.ts
│   │   ├─── publicacion.entity.ts
│   │   ├─── seguidor.entity.ts
│   │   ├─── ...
│   ├─── useCases
│   │   ├─── usuarios.usecase.ts
│   │   ├─── publicaciones.usecase.ts
│   │   ├─── seguidores.usecase.ts
│   │   ├─── ...
│   ├─── index.ts
├── infrastructure
│   ├─── adapters
│   │   ├─── database.adapter.ts
│   │   ├─── ...
│   ├─── database
│   │   ├─── index.ts
│   ├─── repositories
│   │   ├─── usuarios.repository.ts
│   │   ├─── publicaciones.repository.ts
│   │   ├─── seguidores.repository.ts
│   │   ├─── ...
│   ├─── utils
│   │   ├─── utils.ts
│   ├─── index.ts
├── index.ts
├── package.json
├── tsconfig.json


**Explicación:**

_api_: Contiene los controladores, middlewares y rutas de la API.

_application_: Contiene la configuración de la aplicación, 

_modelos_, repositorios, servicios y utilidades.

_domain_: Contiene las entidades y casos de uso del dominio de la aplicación.

_infrastructure_: Contiene los adaptadores, la base de datos y los repositorios de la infraestructura.

_index.ts_: Archivo principal que inicia la aplicación.

_package.json_: Contiene las dependencias del proyecto.

_tsconfig.json_: Contiene la configuración del compilador TypeScript.

**Consideraciones**

Esta es una estructura de archivos básica, puede modificarse según las necesidades específicas del proyecto.

Se recomienda usar un contenedor de dependencias para inyectar las dependencias en las diferentes clases.

Se pueden usar herramientas como NestJS para facilitar la implementación de Clean Architecture.
Revolutionizing Transportation The Era of Programmable Cars
Tags: programming, productivity, webdev, javascript
Published: 2024-04-05 20:26:35

In a groundbreaking leap forward, the automotive industry has ushered in a new era where cars are controlled entirely by programming. Gone are the days of traditional manual driving or even automated systems; now, vehicles are powered by sophisticated algorithms and code.

Imagine stepping into your car and inputting coordinates into a sleek dashboard interface. With a few keystrokes, your vehicle seamlessly navigates through city streets or embarks on a cross-country journey, all without human intervention. This cutting-edge technology promises unparalleled safety and efficiency on the roads.

The possibilities are endless with programmable cars. Developers continuously refine and enhance the software, ensuring optimal performance and adapting to ever-changing traffic conditions. Through machine learning algorithms, these vehicles learn from each trip, becoming smarter and more intuitive with every mile driven.

Furthermore, the advent of programmable cars revolutionizes the concept of transportation accessibility. With customizable settings catering to diverse needs, individuals with disabilities find newfound freedom and independence behind the wheel.

However, as with any technological advancement, challenges lie ahead. Ethical considerations regarding data privacy, cybersecurity, and the impact on traditional driving industries must be carefully addressed.

Nevertheless, the dawn of programmable [pilot and cars](https://pilotandcar.ae/chauffeur-service-dubai/) marks a pivotal moment in history, reshaping how we perceive and interact with automobiles. As we navigate towards a future driven by innovation, one thing is certain: the road ahead is paved with endless possibilities.
🚀💼 Lean Startup: Transforming Tech with Lean Principles 💼🚀
Tags: productivity, product, agile, management
Published: 2024-04-05 20:04:15

I've been captivated by The Lean Startup by Eric Ries. It masterfully adapts lean manufacturing to the tech startup scene, championing agility, rapid iteration, and customer focus. The book isn't just theory; it's a practical guide to innovating more effectively and efficiently, valuable for anyone in tech.

Key Insights & Real-World Applications:

1. Build-Measure-Learn Loop: This core loop is about turning ideas into products quickly, then measuring how customers respond and learning whether to pivot or persevere. A vivid example from the book is Ries' own experience with IMVU, where initial assumptions about customer needs led to rapid iterations before finding a successful product market fit.

2. Validated Learning: This principle involves learning what customers really want, saving time and resources. The book discusses how startups like Dropbox used a simple video to validate customer interest in their product concept before building it, significantly reducing unnecessary development work.

3. Pivot or Persevere: Deciding whether to pivot (change direction) or persevere (continue with the current strategy) is crucial. Ries shares the story of how a pivot in the development strategy, from focusing on complex technology to understanding what was truly valuable to customers, led to the success of Zappos.

4. Innovative Accounting: Setting up metrics that demonstrate clear progress toward the goal. Ries emphasizes the importance of actionable metrics over vanity metrics through examples like Aardvark, a company that pivoted based on learning from customer interactions, which eventually led to its acquisition by Google.

5. Sustainable Growth: Ries explains that sustainable growth comes from products that cause customers to refer others. The example of Votizen, leveraging users' social networks to drive growth, illustrates how focusing on features that encourage referrals can create a self-sustaining growth loop.

I'm curious to hear about your experiences with Lean Startup principles. Have they shaped your approach to projects or leadership? Let's share success stories, challenges or limitations in these methodologies.
Boost Your JSON Workflow with "JSON Dot Search" for VS Code!
Tags: webdev, javascript, programming, json
Published: 2024-04-05 20:02:14

## Do you spend too much time navigating complex JSON files?  Say goodbye to tedious searches and hello to efficiency with "JSON Dot Search"!

This new VS Code extension empowers you to:

- **Effortlessly search JSON files using dot notation strings**.
Simply type the path of the element you're looking for, and the extension will take you right there. This intuitive approach saves you precious time and streamlines your workflow.

- **Copy the path of the current JSON element in dot notation**. No more manually constructing paths – "JSON Dot Search" does the work for you, allowing you to quickly reference elements in your code or documentation.

**Key features**:

- **Powerful dot notation search for pinpoint accuracy**
- **Convenient path copying for streamlined workflows**
- **Easy installation directly from the VS Code Marketplace**

Download Link: Search for "JSON Dot Search" in the VS Code extensions view or visit the VS Code Marketplace: link to VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=VincenzoChiavetta.json-dot-search

P.S. Feel free to share your thoughts and suggestions in the comments below!

{% embed https://github.com/en1-gma/json-dot-search %}
I've started a blog ✨️
Tags: discuss, community, productivity, learning
Published: 2024-04-05 19:48:10

So, it's been my dream to blog about the important things that I encounter which may stem from the fact that I journal almost daily. 

Thanks to Dev.to community that I've finally started it and got almost 300 followers🎉🎉🎉. Thank you so much you guys 🥰❤️❤️❤️


PS : Written a blog on overcoming Procrastination on Hashnode. Do give it a read 📚 
<a href="https://tanujav.hashnode.dev/8-japanese-productivity-hacks-to-over-come-procrastination">Productivity Techniques</a>

> Edit : Thanks for 2.2K+ followers

If you enjoy my content, support me by following me on my other socials😍:
https://linktr.ee/tanujav7
Accessing Remote Servers with Telnet (Use with Caution!)
Published: 2024-04-05 19:47:01

Telnet is a TCP protocol on port 23 used to access remote servers. While it can be useful in specific situations, it's important to be aware of its security limitations. Telnet transmits data unencrypted, making it vulnerable to eavesdropping.

For those comfortable with the risks, here's how to activate Telnet on Windows and connect to a remote chess server:

Enable Telnet Client: Search for "Turn Windows features on or off" in your settings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsjntjo096pm8zgt2hx7.png)



Locate "Telnet Client" and enable it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qli0tezjwi111jhf0em0.png)



Run Command Prompt as Administrator: Open Command Prompt and right-click to choose "Run as administrator."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htkd8c5pr8ha3ky080vi.png)



Connect to Chess Server: Type: 
```
telnet freechess.org 5000
```
and press Enter. You should connect to the server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqaxergutqcgbs0udbvf.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htveka0scetihd2eduhx.png)




Important Note: After using Telnet, remember to disable the Telnet Client for security reasons. Consider more secure alternatives like SSH (Secure Shell) for frequent remote access needs.

Additional Tips:

Telnet is best suited for testing purposes on private networks.

Explore secure remote access options like SSH for everyday use.

I hope this helps! Let me know in the comments if you have any questions.
Application Of The Multiple Return Function
Tags: go, golan, gogroup, backend
Published: 2024-04-05 19:45:31

How to create a function that has a return value is not difficult. Just write when declaring the function all the data types of the values to be returned and in the return keyword write all the data you want to return. An example can be seen below.

```
package main
import "fmt"
import "math"
func calculate(d float64) (float64, float64) {
 // calculate area
 var area = math.Pi * math.Pow(d / 2, 2)
 // calculate the circumference
 var circumference = math.Pi * d
 // return the  two value
 return area, circumference
}
```
The calculate() function above accepts one parameter (diameter).
used in the calculation process. In this function there are 2 things
calculated, namely the area and perimeter values. These two values are then combined
as the return value of the function.
How to define multiple return values can be seen in the code above, write it straight away
data type all return values are separated by commas, then added brackets in
among them.

```
func calculate(d float64) (float64, float64)
```
Don't forget that in the section for writing the return keyword you must also write down all the data
which is used as the return value (with a comma).

```
return area, circumference

```

The implementation of the calculate() function above can be seen in the following code.

```
func main() {
 var diameter float64 = 15
 var area, circumference = calculate(diameter)
 fmt.Printf("luas lingkaran\t\t: %.2f \n", area)
 fmt.Printf("keliling lingkaran\t: %.2f \n", circumference)
}
```

Hope it is usefull
Keep Going
Introvertish to Extrovertish
Tags: discuss, webdev, programming, introvert
Published: 2024-04-05 19:40:06

Through my self-awareness, I have noticed a strange phenomenon occurring within my personality. Ever since I entered the field of Computer Science and started working with Web/Software Technology, my time spent with computers—both at work and during my leisure time—has increased significantly. I don’t mind this at all since it’s my passion; however, it seems that something deep within me did get affected, as my personality trait has shifted from the introverted side of the spectrum to somewhere in the middle, leaning towards the extroverted side. 

I’ve noticed this change in myself as I now initiate conversations more often, even with strangers in public. This is not to say that I used to be anti-social (I'm more inclined to be anti-social-media, hehe); I enjoy socializing, but I didn’t often initiate conversations before. Maybe it's just an age thing as I start my new chapter of life in my 30s :') or perhaps the Web Development field lowkey improves your social skills, which is certainly not a bad thing! I'm not complaining, but I worried that this field would make me even more introverted, which is not entirely a bad thing.

This evolution, however, has proven advantageous, particularly in my role as a front-end web developer. Effective communication is paramount in understanding clients’ needs and collaborating with a development team to devise solutions. The ability to step forward and connect with others has enriched these professional exchanges and I look forward to applying myself in my career.

I’m curious to know if other introverts have experienced a similar transformation or conversely, have any extroverts found themselves gravitating towards introversion? Either way, you're all cool :)

(PS - my first post, salud!)