Craigslist Finally Gets an Official App

Craigslist Finally Gets an Official App

https://ift.tt/33OVn0H

Craigslist has long been a staple of the internet since it first launched in 1995—but surprisingly, it hasn’t had an official app in the decade or so since the smartphone era began. Well, that’s all changed. You can now find the official, free app for iOS.

Like the website, the mobile app is extremely simple—no frills, bells, or whistles. The app’s overall design mimics the website as well, meaning its mostly just text and a clean interface. As you’d imagine, that makes the app extremely fast and easy to load. There’s also a post tab that streamlines posting straight from your phone. Not that making a Craigslist post was ever hard, but the app does make the process a lot smoother.

Even the app’s description is the bare minimum. One could say it reads like a haiku or at least some sort of Hemingway-esque musing on internet life.

craigslist – The original online classifieds. Established 1995.

Find jobs. Hire employees. Post your resume. Offer your skills/services.

Buy & sell cars, trucks, boats, RVs, motorcycles, trailers, auto parts.

Offer your services, locate contractors, find short term gigs and odd jobs.

Buy & sell furniture, household items, electronics, computers, clothing, bikes, art, any and all kinds of used items.

Activity partners, artists & musicians, pets for rehoming, local events.

Save your favorite postings for later, save searches, set search alerts.

Post, edit, renew your own ads.

Right now, the app ranks No. 14 in the App Store’s shopping category and has an overall 4.6 out of 5 star rating from 63 reviews. Not too shabby considering version 1.0 dropped just yesterday. It’s only mildly surprising that the launch has been so quiet. The site stealthily launched beta testing for the official app on its website an indeterminate time ago, though it’s not that easy to find the link on the main site. Although a search in the Google Play Store only turns up third-party apps at the moment, you can find a link to the Android beta test here.

[9to5 Mac]

geeky,Tech

via Gizmodo https://gizmodo.com

December 4, 2019 at 12:33PM

Marvel’s new ‘Black Widow’ trailer teases the spy thriller Natasha Romanoff deserves

Marvel’s new ‘Black Widow’ trailer teases the spy thriller Natasha Romanoff deserves

https://ift.tt/34KO6A5

Marvel has a trailer out for Black Widow, the story focused on the member of the Avengers team played by Scarlett Johansson. This preview of the movie features a lot of heart-pumping action, and an all-star cast that includes Rachel Weisz, Florence Pugh, David Harbour, and of course, Johansson herself.

What we get in this trailer is a look at a movie that appears to span multiple genres – it starts off looking very much like a Bourne-esque spy thriller with exciting, somewhat gritty hand-to-hand fight scenes. Later on, though, it seems to show more superhero vibes in the tradition of the big and glossy Marvel cinematic universe, though leaning more towards Captain America: Winter Soldier than the big tent circus set pieces of the core Avengers lineup, or the wacky, neon glare of the Guardians franchise and the most recent Thor.

Black Widow’s Russian spy background is clearly on display here, and it looks like there’s going to be a very weird ‘family reunion’ on display with some Russian heroes. Overall, it looks entertaining as heck – and it has a lot to live up to, as the first Marvel Studios film after Avengers: Endgame (Spider-Man: Far From Home only gets partial credit because of the shared character ownership with Sony).

technology

via TechCrunch https://techcrunch.com

December 3, 2019 at 07:57AM

Cache Eloquent queries in Laravel 6

Cache Eloquent queries in Laravel 6

https://ift.tt/2IPx22y

The package can be found on GitHub, where the documentation will approach all of the main points of the app. However, during this article, you’ll learn just the basics of caching and clearing cache so you can get started before you will dig deeper.

Installation

The package can be installed through Composer:

$ composer require rennokki/laravel-eloquent-query-cache

Your models will need the QueryCacheable trait:

use Rennokki\QueryCache\Traits\QueryCacheable;class Article extends Model
{
use QueryCacheable;
...
}

Enable the caching behavior by default

By default, the package does not enable query caching. To achieve this, add the $cacheFor variable in your model:

use Rennokki\QueryCache\Traits\QueryCacheable;class Article extends Model
{
use QueryCacheable;
protected $cacheFor = 180; // 3 minutes
}

Whenever a query will be triggered, the cache will intervene and in case the cache is empty for that query, it will store it and next time will retrieve it from the caching database; in case it exists, it will retrieve it and serve it, without hitting the database.

// database hit; the query result was stored in the cache
Article::latest()->get();
// database was not hit; the query result was retrieved from the cache
Article::latest()->get();

If you simply want to avoid hitting the cache, you can use the ->dontCache() before hitting the final method.

Article::latest()->dontCache()->firstOrFail();

Enable the caching behavior query-by-query

The alternative is to enable cache query-by-query if caching by default doesn’t sound like a good option to you.

First of all, remove the $cacheFor variable from your model.

On each query, you can call ->cacheFor(...) to specify that you want to cache that query.

Article::cacheFor(now()->addHours(24))->paginate(15);

Organize better with tags

Some cache storages, like Redis or Memcached, come up with the support of tagging your keys. This is useful because we can tag our queries in-cache and invalidate the needed cache whenever we want to.

As a simple example, this can be useful if we want to invalidate the articles list cache when one article gets updated.

$articles = Article::cacheFor(60)->cacheTags(['latest:articles'])->latest()->get();$article = Article::find($id);
$article->update(['title' => 'My new title']);
Article::flushQueryCache(['latest:articles']);

The method flushQueryCache invalidates only the caches that were tagged with latest:articles. If some other queries would have been tagged with tags other than latest:articles, they would be kept in the cache.

Digging deeper

For more about this package, check out the project’s page on GitHub.

programming

via Laravel News Links https://ift.tt/2dvygAJ

December 3, 2019 at 08:36AM

Interview With Stephen Willeford, the Hero of Sutherland Springs

Interview With Stephen Willeford, the Hero of Sutherland Springs

https://ift.tt/2OFgZIq

Stephen Willeford, the Hero of Sutherland Springs
Stephen Willeford, the Hero of Sutherland Springs

Sutherland Springs, TX-(Ammoland.com)- Stephen Willeford is the epitome of the definition of a “good guy with a gun.”

On November 5, 2017, a mad man entered the First Baptist Church in Sutherland Springs, TX, and opened fired on the Church congregation. The attacker killed 26 members of the church and wounded 20 other worshippers. He then fled the house of worship to continue his attacks.

Stephen Willeford, an NRA instructor and firearms enthusiast, knew he must do something to stop the killer’s deadly rampage. He couldn’t sit around and let a maniac attack his community. He grabbed his AR-15 and set out to end the murderer’s violent spree.

Willeford engaged the killer as he was leaving the church. A gunfight erupted in the parking lot. Willeford hit the killer twice, once in the leg and once in the upper left torso under the attacker’s tactical vest. The killer dropped his AR-15 and fired on Willeford with a pistol before speeding off in his Ford Explorer.

Willeford saw a pickup truck driven by Johnnie Langendorff. He approached the truck and jumped in the passenger seat. The two men chased the killer’s Explorer for seven minutes at speeds approaching 95 miles an hour.

Soon the killer lost control of his vehicle and ended up 30 feet into a field on the opposite of the road. Willeford and Langendorff noticed the attacker wasn’t moving and kept the ford covered until police arrived on the scene. The police found the killer dead of a self-inflicted gunshot wound.

I had a chance to speak with Stephen about his views on guns and what happened on that fateful day in Sutherland Springs, TX.

John: What is your background with guns?

Stephen: I grew up on a dairy farm where I learned to shoot a .22 Remington Scoremaster when I was five years old. My father taught me how to shoot tin cans and eventually hunt rabbits and shoot snakes and coyotes on the farm. Firearms were an integral part of life on a farm. As an adult, I entered shooting competitions with pistols and rifles at a San Antonio shooting range called Blackhawk. I also helped coach a youth shooting club at Blackhawk, where we trained the youth in firearms safety and marksmanship. I believe teaching the next generation to shoot is essential.

John: How did you find out the shooting in the church was happening?

Stephen: My oldest daughter heard the shots and made me aware of it.

John: What made you engage the shooter?

Stephen: I knew my community needed the shooting to stop. I arrived before law enforcement. He came out of the building, shooting at me. I truly believe God had called me to go there and stop it.

John: A lot of people think you are a hero. Do you believe that you are one?

Stephen: I prefer to consider myself a sheepdog, following my shepherd and protecting his flock. There are a lot of other sheepdogs in this world that would have done the same thing if they had been there.

John: Were you scared?

Stephen: I wasn’t scared at all. I was terrified. But the Holy Spirit was with me, telling me not to concern myself with the bullets coming my way, but to do what he sent me to do.

John: How has your life changed since the incident?

Stephen: I have traveled to places around the nation, speaking to churches and other groups about the need to be vigilant and ready if this were to happen in their communities by forming Safety Response Teams. I have spoken to politicians about good policies to prevent criminals from getting guns instead of the knee-jerk reactions they usually have of penalizing law-abiding citizens by enacting gun control measures that do nothing but make them feel better. I have met with several law enforcement agencies, encouraging their members and letting them know that they are appreciated, in spite of the negative media narrative.

John: What do you think about people that blame the gun for the church shooting?

Stephen: It is easy to blame the gun for the shooting because it takes away the responsibility of each individual for their actions. It is actually a matter of the heart, good vs. evil. That is a lot harder to fix. This country needs to go back to what God values, life. From conception to death. Until we can instill that in our society, these incidents will continue. Life matters — all lives. And individual responsibility is a key to stopping these kinds of things. A firearm is a tool, and nothing more.

John: Were you prepared to be thrown in the spotlight?

Stephen: Not at all. I tried to stay out of it. But now I have a voice that I believe can make a difference.

John: You campaigned with Ted Cruz. Is it important for you to help pro-gun candidates?

Stephen: It is important to help pro-gun candidates and good Godly men and women who are willing to stand up for our rights that are protected by the Constitution.

John: Do you think we can defeat the gun-control movement?

Stephen: I think we HAVE to defeat the gun-control movement if we want to save our Republic. We have to educate those who are uninformed about firearms and our Constitution.

John: Why is the Second Amendment important to you?

Stephen: Without the Second Amendment, the right to defend ourselves and our community, the rest of the Amendments, our Constitution and our Nation as we know it will fall. We need to protect it for our children, our grandchildren, and our grandchildren’s grandchildren.

John: Anything else you want our readers to know?

Stephen: Firearm owners are not the threat that people should be afraid of. Go out and get trained. Even the best of shooters need to continue to train. Start thinking about the mindset of a sheepdog. Look out for your family, your neighbors, your friends, your community. You can make a difference.

Stephen Willeford, the Hero of Sutherland Springs
Stephen continues to use his voice to advance gun rights

Stephen continues to use his voice to advance gun rights.


About John CrumpJohn Crump

John is a NRA instructor and a constitutional activist. He is the former CEO of Veritas Firearms, LLC and is the co-host of The Patriot News Podcast which can be found at www.blogtalkradio.com/patriotnews. John has written extensively on the patriot movement including 3%’ers, Oath Keepers, and Militias. In addition to the Patriot movement, John has written about firearms, interviewed people of all walks of life, and on the Constitution. John lives in Northern Virginia with his wife and sons and is currently working on a book on leftist deplatforming methods and can be followed on Twitter at @crumpyss, on Facebook at realjohncrump, or at www.crumpy.com.

The post Interview With Stephen Willeford, the Hero of Sutherland Springs appeared first on AmmoLand.com.

guns

via AmmoLand.com https://ift.tt/2okaFKE

December 2, 2019 at 07:06PM

Justices Hear Arguments In SCOTUS Showdown Over NYC Gun Case

Justices Hear Arguments In SCOTUS Showdown Over NYC Gun Case

https://ift.tt/2We72WK

As the Supreme Court heard oral arguments Monday morning in the New York State Rifle & Pistol Association v New York City case, gun control activists rallied outside the court in support of gun restrictions, though many of them were oddly silent on the specifics of this case.

Townhall.com’s Julio Rosas joined me from the Court for today’s program, and I also speak with Philip Van Cleave of the Virginia Citizens Defense League about the surge in Second Amendment Sanctuary counties across the state. I’ll have a separate post on the latest in Virginia but right now let’s talk about the Supreme Court and what it’s likely to do with the case now that justices have heard from both sides.

The biggest question at the moment is whether or not the Court will dismiss the case due to mootness. Transcripts of today’s oral arguments are now now available if you want to read for yourself, but most of the press coverage of the arguments indicates that Chief Justice John Roberts might be the deciding vote on whether the case goes forward and the Court rules on the New York City gun law in question, or if the city’s attempt to moot the case by changing the law a couple of months ago (after defending the law for several years) will end the litigation. From Reuters:

Conservative Justices Samuel Alito and Neil Gorsuch were most vocal in advocating for the court to issue a ruling. Chief Justice John Roberts, who could be a pivotal vote in the case, said little but asked whether the city residents who challenged the law would face consequences for violations of the prior regulation.

The legal challenge takes aim at a regulation that had prevented licensed owners from taking their handguns to other homes or shooting ranges outside the confines of the most-populous U.S. city. The regulation was amended in July to allow for such transport.

“What’s left of this case?” asked liberal Justice Ruth Bader Ginsburg. “Petitioners got all the relief they sought.”

Not really. As former Solicitor General Paul Clement, who’s representing the New York State Rifle & Pistol Association, told the court, some of the provisions of the revised law could still cause city residents to break the law if they so much as stop to get a cup of coffee on the way to the range. Clement also argued that, given the fact that the city didn’t change the law in question until after the Supreme Court agreed to hear the case, there’s no reason to believe the city was acting in good faith and wouldn’t simply change the law again if the lawsuit is dismissed.

Vox is claiming that Chief Justice John Roberts appeared sympathetic to the city’s position, but I would caution folks from trying to read too much into the questions asked by justices during the oral arguments. Moreover, even Vox acknowledges that if the Supreme Court decides that the New York City gun case is moot, there are other Second Amendment cases queued up and ready for the Court’s attention.

Meanwhile, while New York State Rifle is likely to be declared moot, there is another Second Amendment case — Rogers v. Grewal — that the Supreme Court could take up as soon as Friday. The questions presented in Rogers include “whether the Second Amendment protects the right to carry a firearm outside the home for self-defense.”

If New York State Rifle is declared moot, the Court could simply take up the Rogers case — and there’s still plenty of time for the Court to decide that case before its current term ends this June.

New York State Rifle, in other words, appears likely to end in the tiniest possible victory for gun control. The case will likely be dismissed as moot, but a Second Amendment reckoning is all but inevitable in the Supreme Court. And it’s likely to come very soon.

That’s the good news for gun owners. The Supreme Court has been holding the Rogers case for months now, and the speculation is that the Court did so pending the outcome of NYSRPA v. NYC. If the Court does decide that the case is still a live issue, the majority opinion could have an impact on the New Jersey carry case, and they could send Rogers back to the 3rd Circuit Court of Appeals with guidance directed by the NYSRPA v NYC opinion.

If, on the other hand, the Court does moot the New York case, it has Rogers to pick up instead, and the Court would be dealing with a much more explicit challenge to the infringement on the right to bear arms than the New York City case presents.

If the Supreme Court decides that the New York Case is moot, I’d expect a decision to come fairly quickly. If the Court does move forward with the case, expect a ruling in several months.

When the oral argument transcripts are made available, you’ll be able to access them here. In the meantime, check out today’s show with Julio Rosas and VCDL’s Philip Van Cleave, and we’ll be keeping an eye on any future developments at the Supreme Court.

Also on today’s show, we have an armed citizen story from Missouri, a criminal justice fail from Baltimore, and an off-duty officer who performed a very good deed in the parking lot of a fast food restaurant in the suburbs of Richmond, Virginia.

Don’t forget to subscribe to the show at Apple Podcasts, Spotify, Stitcher, or Townhall.com’s podcast page. We’ll have much more reaction to today’s oral arguments on tomorrow’s show, so be sure to tune in.

 

Author’s Bio:

Cam Edwards

Cam Edwards Cam Edwards has covered the 2nd Amendment for more than 15 years as a broadcast and online journalist, as well as the co-author of "Heavy Lifting: Grow Up, Get a Job, Start a Family, and Other Manly Advice" with Jim Geraghty. He lives outside of Farmville, Virginia with his family.

https://ift.tt/32B3Y6X

guns

via Bearing Arms https://ift.tt/2WiVJN5

December 2, 2019 at 02:10PM

Top Free WordPress HelpDesk Plugins for Improved Customer Relationships

Top Free WordPress HelpDesk Plugins for Improved Customer Relationships

https://ift.tt/2L1LGWa

Providing exceptional customer support is one of the major concerns of business owners. Customers should be able to interact with you and get resolutions for problems they may be facing with your products or services.

If you have a WordPress website, you can easily incorporate a support ticket system with the help of help desk plugins. They will help you provide customer support in an organized, specific manner on your website. In this article, we will look at some of the best free WordPress helpdesk plugins to help you enhance your customer relationship management.

How to improve customer relationships?

Maintaining great customer relationships is key to the success of any business. You need to focus on several aspects while interacting with customers in order for them to come back to your site. Here are a few best practices suggested by specialists to improve online customer relationships.

Create a dedicated helpdesk system with experts

If you have an eCommerce store with multiple products, you might get varied queries from customers. One of the keys for customer support success is to develop a team of support agents with adequate expertise on each of your products. This will help in the more effective resolution of user issues, as the experts will be able to offer quick solutions.

Develop a systematic workflow

Now, you may have an expert team with great product knowledge. However, without a systematic workflow that will assign the query to the right agent, your support system won’t be as effective. So, it is important to design a workflow and execute it well enough to ensure that customer issues are solved accurately and quickly. A lot of popular WordPress helpdesk plugins offer options to automate your customer support workflow. If you have multiple products and multiple departments, automation options could really add a lot of value to your customer support.

Use customer feedback to improve efficiency

Now, you cannot just go out there and build the most efficient help desk. It will take time to optimize your customer support system, and one of the most important contributors to this will be customer feedback. You should make sure to have a system to collect regular feedback from your customers. Competent helpdesk systems will incorporate customer feedback as an essential component. Apart from the direct feedback, you can also use other metrics like resolution time, agent rating, periodic variations, etc. If you are using an online helpdesk system, ensure that there is an option to gather customer feedback consistently.

Try multiple channels

In the current digital environment, customers interact through different channels. So, in order to take into account different preferences of your customer base, you may need to invest in different support channels. Depending on the interests of your customers and industry trends, you can opt from different channels like telephone, email, live chat, social media, etc for multi-channel customer support.

Use a superior online helpdesk system

Now, one of the fundamental aspects you have to focus on to set up an efficient customer support system is to invest in a good helpdesk system. Finding a comprehensive helpdesk system that offers you advanced features is an important step towards this. Most of the modern customer support software offers useful features like workflow automation, canned responses, customizable contact forms and so on. It is important to find a helpdesk solution that is effective for your business model. Before choosing the software, go through the features and make sure that it is the right fit for your specific needs.

Best WordPress Helpdesk plugins

If you have a WordPress website, you will need a customer support tool that will integrate seamlessly with your website. Here is a list of some of the top WordPress helpdesk plugins that will help you create long-lasting customer relationships.

WSDesk

WSDesk is one of the most popular WordPress helpdesk plugins to help you improve the customer support process on your website. The free version of this plugin has a large range of features to help you set up an online support system. Compared to some of the other free plugins, this plugin is really exceptional in terms of the features offered with the free version. Unlimited tickets and agents, email piping, customizable email replies, file attachment options, etc are some of the standout features.

Features

  • Ajax-based user interface to contribute to fast page loading and thereby faster resolution of customer issues.
  • Complete control of user data, unlike popular SaaS-based helpdesk tools.
  • Helps agents to track, prioritize and resolve issues quickly and ensure the superior customer experience.
  • Open source helpdesk system, which helps developers make feature additions, modifications and bug fix easily.
  • Unlimited support tickets and agents.
  • Easily convert emails to your support mail id into tickets, and filter them to avoid spam
  • Detailed analytics reports measuring agents’ performance and customer experience.
  • Customizable ticket fields and support forms.
  • File attachment options to help address issues with more details.

JS Help Desk

Formerly JS Support Ticket, JS Help Desk is a simple and user-friendly customer support plugin that you can use on your WordPress site. Your customers will be able to create a support ticket from the website’s frontend. And, your support agents will be able to work on them from the backend with the help of advanced features and provide quick resolutions. As the plugin follows all the best practices in coding, you can expect it to create no hassles with your site’s speed and performance.

Features

  • Allows customers and guests to create support tickets from the frontend of your website.
  • Filters to sort the tickets effectively for both customers and support agents.
  • Several advanced features to help support agents including multiple file attachments, priority highlighting, auto assigning, etc.
  • Option to set up ticket notifications to users and agents according to specific requirements.
  • Shortcodes to help you create and place ticket forms conveniently.
  • Simple user interface for site admins to add or modify tickets, manage ticket status and create email replies.
  • The plugin has a bootstrap based design and allows easy translation.

SupportCandy

This is a popular WordPress plugin that will help you create a robust helpdesk system on your website. Setting up and interacting with customers using this plugin is exceptionally easy, and it makes it quite popular among WordPress site owners. The plugin ensures GDPR compliance and gives you no hassles with regards to users’ personal data. You can download and use the free plugin from the WordPress plugin repository. However, you will find premium add-ons for WooCommerce integration, email piping, canned responses, agent assign rules, and several other advanced features.

Features

  • No limit to the number of agents and tickets that can be created using the free version of this plugin.
  • Ajax functionality contributes to a very fast user interface.
  • Agents can manage the ticket data from the frontend with the help of agent-specific additional fields, filters, and sorting options.
  • Option to allow guest users to raise a ticket on your website.
  • Several custom field options to create the most suitable support form for your business.
  • Create multiple attachment fields along with an option to attach files in the ticket descriptions.
  • Unique fields are visible only to support agents and options for agents to add internal notes.
  • Customizable email notification templates.
  • Responsive, mobile friendly design and supports developer level customization.

Zendesk Support for WordPress

You can use this plugin to integrate Zendesk customer support system on your WordPress site. Once you have installed this plugin on your website, your users will not have to sign in separately to Zendesk to raise a ticket. The plugin also helps to automatically convert your blog comments into tickets. It also lets you add a support widget anywhere on your pages or posts as you deem fit. Moreover, you can easily collect feedback from your users to improve the efficiency of your customer support process. Please note, you will have to sign up for a Zendesk account to be able to use this plugin. You can try out the Zendesk support system for a 30-day free trial.

bbPRess

If you are looking to create a discussion forum on your WordPress site, and not create a full-fledged help desk system, you can use bbPress. You can easily install and configure it, and let your customers find answers to several common queries they may encounter on your site. The interface is quite similar to WordPress and hence you can easily manage it even if you are a beginner to WordPress. bbPress offers a range of add-ons to help you customize it the way you want it. Moreover, it comes with a lot of theme options that will help you control the look and feel of the forum.

Conclusion:

Hope this article has provided you a few strategies and tools to improve your customer relationships. Keep in mind that you need to build a loyal customer base to grow your business. Leave a comment if you have a query.

Creator: Vijay, the founder of ELEXtensions.com & LearnWoo.com, and you can get in touch with him via his Twitter.

via Noupe https://www.noupe.com

November 28, 2019 at 02:32AM

5 JavaScript Array Methods You Should Master Today

5 JavaScript Array Methods You Should Master Today

https://ift.tt/2OvoQbz

javascript-array-methods

Web developers of all skill levels, from rookie programmers to coding experts, come to see the importance of JavaScript in developing modern websites. JavaScript is so dominant that it is an essential skill to know if you’re going to create apps.

One of the most powerful building blocks built-in to the JavaScript language is arrays. Arrays are commonly found in many programming languages and are useful for storing data.

JavaScript uses arrays but adds useful features known as array methods. There are five you should take a close look at to grow your skills as a developer.

What Are Array Methods?

Array methods are functions built-in to JavaScript that you can apply to your arrays. Each method has a unique function that performs a change or calculation to your array, saving you from needing to code common functions from scratch.

Array methods in JavaScript are ran using a dot-notation attached to your array variable. Since they are just JavaScript functions, they always end with parenthesis which can hold optional arguments. Here is a method attached to a simple array called myArray.

var myArray = [1,2,3];
myArray.pop();

This code would apply a method called pop to the array.

Example Array

For each example let’s use a sample array that we will call myArray, to perform the methods on. Feel free to pull up your console and code along as we go.

var myArray = [2,4,5,7,9,12,14];

These examples will assume you know the foundation of what JavaScript is and how it works. If you don’t that’s okay, we’re all here to learn and grow.

Let’s dig into five powerful methods!

1. Array.push()

What it does: push() takes your array and adds one or more elements to the end of the array, then returns the new length of the array. This method will modify your existing array.

Let’s add the number 20 to the array by running push(), using 20 as an argument.

var myArray = [2,4,5,7,9,12,14];
myArray.push(20);

Let’s see if it worked

console.log(myArray);
[2,4,5,7,9,12,14,20]

Running the push() method on myArray added the value given in the argument into the array. In this case, 20. When you check myArray in the console, you will see the value is now added to the end of the array.

2. Array.concat()

What is does: concat() can merge two or more arrays together into a new array. It does not modify the existing arrays but creates a new one.

Let’s take myArray and merge an array called newArray into it.

var myArray = [2,4,5,7,9,12,14];
var newArray = [1,2,3];
var result = myArray.concat(newArray);
console.log(result);
[2,4,5,7,9,12,14,1,2,3]

This method works wonders when dealing with multiple arrays or values you need to combine, all in one pretty simple step when using variables.

3. Array.join()

What it does: join() takes an array and concatenates the contents of the array, separated by a comma. The result is placed in a string. You can specify a separator if you want to use an alternative to a comma.

Let’s take a look at how this works using myArray. First using the default method with no separator argument, which will use a comma.

var myArray = [2,4,5,7,9,12,14];
myArray.join();
"2,4,5,7,9,12,14"

JavaScript will output a string, with each value in the array separated by a comma. You can use an argument in the function to change the separator. Let’s see it with two arguments: a single space, and a string.

myArray.join(' ');
"2 4 5 7 9 12 14"
myArray.join(' and ');
"2 and 4 and 5 and 7 and 9 and 12 and 14"

The first example is a space, making a string you can easily read.

The second example uses (‘ and ‘), and there are two things to know here.

First, we’re using the word ‘and’ to separate the values. Secondly, there is a space on both sides of the word ‘and’. This is an important thing to keep in mind when using join(). JavaScript reads arguments literally so if this space is left out, everything will be scrunched together (ie. “2and4and5…” etc.) Not a very readable output!

4. Array.forEach()

What it does: forEach() (case sensitive!) performs a function on each item in your array. This function is any function you create, similar to using a “for” loop to apply a function to an array but with much less work to code.

There is a little bit more to forEach() so let’s look at the syntax, then perform a simple function to demonstrate.


myArray.forEach(function(item){
//code
});

We’re using myArray, forEach() is applied with the dot notation. You place the function you wish to use inside of the argument parenthesis, which is function(item) in the example.

Let’s talk about function(item). This is the function executed inside of forEach(), and it has its own argument. We’re calling the argument item. There are two things to know about this argument:

  • When forEach() loops over your array, it applies the code to this argument. Think of it as a temporary variable that holds the current element.
  • You choose the name of the argument, it can be named anything you want. Typically this would be named something that makes it easier to understand, like “item” or “element”.

With those two things in mind, let’s see a simple example. Let’s add 15 to every value, and have the console show the result.


myArray.forEach(function(item){
    console.log(item + 15);
});

We’re using item in this example as the variable, so the function is written to add 15 to each value via item. The console then prints the results. Here’s what it looks like in a Google Chrome console.

forEach Function Applied to Array in JavaScript Console

The result is every number in the array, but with 15 added to it!

5. Array.map()

What it does: map() performs a function on every element in your array and places the result in a new array.

Running a function on every element sounds like forEach(). The difference here is map() creates a new array when ran. ForEach() does not create a new array automatically, you would have to code a specific function to do so.

Let’s use map() to double the value of every element in myArray, and place them in a new array. You will see the same function(item) syntax for a little more practice.

var myArray = [2,4,5,7,9,12,14];
var doubleArray = myArray.map(function(item){
return item * 2;
});

Let’s check the results in the console.

console.log(doubleArray);
[4,8,10,14,18,24,28]

myArray is unchanged:

console.log(myArray);
[2,4,5,7,9,12,14]

Next Steps in Your JavaScript Journey

Arrays are a powerful part of the JavaScript language, which is why there are so many methods built-in to make your life easier as a developer. The best way to master these five methods is to practice.

As you continue to learn JavaScript, MDN is a great resource for detailed documentation. Get comfortable in the console, then take your skills up a notch with the best JavaScript editors for programmers. Happy coding!

Read the full article: 5 JavaScript Array Methods You Should Master Today

non critical

via MakeUseOf.com https://ift.tt/1AUAxdL

November 28, 2019 at 10:47AM