IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] 仕事選びも“タイパ”重視? 我慢できる通勤時間 |
https://www.itmedia.co.jp/business/articles/2304/04/news175.html
|
itmedia |
2023-04-05 09:45:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] AI開発停止要求署名は無意味、透明性と説明責任の改善を──Hugging Faceのルッチョーニ博士 |
https://www.itmedia.co.jp/news/articles/2304/05/news067.html
|
huggingface |
2023-04-05 09:41:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia エグゼクティブ] 国際卓越研究大学に10校申請 東大など 10兆円ファンド支援 秋までに絞り込み |
https://mag.executive.itmedia.co.jp/executive/articles/2304/05/news064.html
|
itmedia |
2023-04-05 09:12:00 |
デザイン |
コリス |
VS Codeでコードがさらに見やすくなる! 行の折りたたみをより使いやすくする機能拡張 -Better Folding |
https://coliss.com/articles/build-websites/operation/work/vscode-extension-better-folding.html
|
続きを読む |
2023-04-05 00:36:09 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
javascript 文字列の中に特定の文字列が存在するかを判定する includes() |
https://qiita.com/miriwo/items/240a80c4bfcd1f0b27e9
|
letstrhogefugapiyocons |
2023-04-05 09:54:02 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
プログラムを調べるとよく出てくる「オブジェクト」とは? |
https://qiita.com/cmzkkhrs/items/03d997ea5313a08bdcbb
|
言語 |
2023-04-05 09:50:08 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
AWS Skill Builder チームサブスクリプションとは - AWS Jamイベントを体験してみた |
https://qiita.com/k-suto-hisys/items/11db8563674154b56572
|
awsjam |
2023-04-05 09:38:19 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Rails – APIモードだがBasic認証を使いたい |
https://qiita.com/YumaInaura/items/3f88790017019c76f0cb
|
classapplicationco |
2023-04-05 09:38:59 |
技術ブログ |
Developers.IO |
EventBridge API Destinations を利用して、Security Hub の検出結果の通知内容をカスタマイズして Slack に通知してみた |
https://dev.classmethod.jp/articles/eventbridge-api-destinations-send-security-hub-findings-result-to-slack-and-customize-notifications/
|
chatbot |
2023-04-05 00:28:04 |
海外TECH |
DEV Community |
Javascript async/await |
https://dev.to/kebean10/javascript-asyncawait-1ah7
|
Javascript async awaitIn this article I will continue to discuss asynchronous code and more specifically how to use async await Before going any further if there is one thing that I want you to take away from this article is this At the end of the day async await allows us to write async code in a synchronous fashion instead of endlessly nesting callbacks main points When we use async await await will always waits till the promise is settled We can only use await when we have async in front of the function this is important because most of the time once people learn async await especially beginners they pretty much start using await all over their code and you can not do that You can only use await if the function that you have set up is actually async async function always returns a promise N B Throughout this article I ll be using the arrow function but if you prefer using the traditional function there is no law against you just go for it General example Showcasing how async function will always return a promiseconst example async gt return Hello world console log example it will show a promise in the console output As you can see it is a promise and it is right away fulfilled Just keep in mind that async will always and always return a promise showcasing how await works const example async gt return Hello world const someFunc async gt const result await example console log result someFunc output From here await will need to wait until the promise from the example function is settled then you can get the result in the console It is very important since you don t have to use then chains instead you ll wait for the promise to be resolved and get the result Real world example Usually you will typically request resources over the wire meaning from the database API or whatever but here I m gonna be using a simple example where I have a user array containing students and classes array containing subjects students are taking const users array of objects containing stundets and their ID id name kebean id name Chico id name Maelle const classes array of objects containing student ID and classes they are taking studentId classesTaken OOP C Net kebean take this class because the ID matches studentId classesTaken Math History Chico take this class because the ID mathches studentId classesTaken Physics Chemistry Geography Maelle take this class because the ID mathches const getUser name gt return new Promise resolve reject gt const user users find user gt user name name if user return resolve user else reject No such user with name name const getClasses studentId gt return new Promise resolve reject gt const userClasses classes find user gt user studentId studentId if userClasses return resolve userClasses classesTaken else reject Wrong ID N B You need to understand that the above functions happen in sequence only once you get the student only then you can access the subject they are studyingSince you are familiar with the above two functions I want to showcase how you can get the data using the typical then approach and later I will showcase how you can achieve the same thing while using async await which is more effective and readable at least in my point of view typical then approachgetUser kebean returns a promise then user gt console log user you will have access to data you pass into resolve catch error gt console log error when there is errors you will catch them hereThe logic is the following you pass in the name if the name matches you will of course get the student and when the name doesn t match you will get the error message output when the user doesn t exist getUser kebeans then user gt console log user catch error gt console log error As you can see the error message will be displayedoutput getUser kebean then user gt getClasses user id invoking getClasses and pass in the user ID then classes gt console log classes the getClasses function above returns classes that match to the user ID or student ID you passed in catch error gt console log error output The problem with the above setup is once you have multiple async operations you will have to start chaining these then which is not readable and long to write This is where async await truly shines because you can make the above code way more readable by refactoring the code to use async await async await approachconst getStudent async gt const user await getUser kebean console log user getStudent output From the above example you can see that it s possible to access the student using async await Let s see also how to access them classes a student can actually take const getStudent async gt const user await getUser kebean if user const classes await getClasses user id console log classes getStudent output BOOM you can get the classes kebean is taking as well Just take a look at the code in both approaches I mean even if the code is pretty much doing the same thing you can clearly see that the approach of using async await is way more readable and short How to Handle errors when using async awaitAs you can see the error can t be handled as expected while using async await take a look at the following code const getStudent async gt const user await getUser kebeans if user const classes await getClasses user id console log classes getStudent output As you can see the student user kebeans with s at the end doesn t exist and instead of getting the error message defined in reject you are getting messy in a console and what you need is to handle that gracefully You can do that by setting up try and catch block like this const getStudent async gt try const user await getUser kebeans if user const classes await getClasses user id console log classes catch error console log error getStudent output conclusionHopefully now you can clearly see why async await has become pretty much the go to when we need to handle asynchronous tasks It improves readability by allowing us to write asynchronous code in a more synchronous style making it easier to read and understand This can also be particularly helpful for developers who are new to asynchronous programming Thanks for reading and happy coding Kebean |
2023-04-05 00:39:25 |
Apple |
AppleInsider - Frontpage News |
Nintendo won't be making any more 'Super Mario' games for iPhone |
https://appleinsider.com/articles/23/04/05/nintendo-wont-be-making-any-more-super-mario-games-for-iphone?utm_medium=rss
|
Nintendo won x t be making any more x Super Mario x games for iPhoneNintendo director and designer Shigeru Miyamoto has confirmed Mario won t be coming back to smartphones like iPhone Mario Run wasn t a big hit on mobileNintendo has released a range of titles on mobile devices like iPhone They have seen middling success but they never penetrated the market in the way such popular intellectual properties usually would Read more |
2023-04-05 00:16:11 |
海外科学 |
NYT > Science |
Outsiders Solve Problems. Just Ask Goats. |
https://www.nytimes.com/2023/04/04/science/goats-camels-outsiders.html
|
Outsiders Solve Problems Just Ask Goats In a study of how animals respond to the unknown goats and camels especially those with a lower social position proved most capable of liberating a snack from a cup |
2023-04-05 00:38:36 |
海外科学 |
NYT > Science |
Highlights From NASA’s Reveal of the Artemis II Moon Astronauts |
https://www.nytimes.com/live/2023/04/03/science/artemis-nasa-news
|
artemis |
2023-04-05 00:19:06 |
金融 |
ニッセイ基礎研究所 |
大学や専門学校への進学と遺族年金-時代に合わせた制度改正を期待 |
https://www.nli-research.co.jp/topics_detail1/id=74423?site=nli
|
このように、残された子が高校を卒業すると遺族年金が減額されるため、大学や専門学校などへの進学の障害になるおそれがある。 |
2023-04-05 09:46:07 |
金融 |
日本銀行:RSS |
庶務職員(自動車運転員)の募集について |
http://www.boj.or.jp/about/recruit/rec230405a.htm
|
運転 |
2023-04-05 10:00:00 |
ニュース |
@日本経済新聞 電子版 |
ZHDがリスキリングで成果 「文系AI人材」増員の先
https://t.co/2yqdTwGTpD |
https://twitter.com/nikkei/statuses/1643417133353938944
|
文系 |
2023-04-05 00:55:52 |
ニュース |
@日本経済新聞 電子版 |
中小企業ベア5199円、22年の2.6倍で最高 物価高を反映
https://t.co/TKZUdt5Aj1 |
https://twitter.com/nikkei/statuses/1643415030950694912
|
中小企業 |
2023-04-05 00:47:31 |
ニュース |
@日本経済新聞 電子版 |
台湾・蔡英文総統、米国に到着へ 下院議長と5日会談
https://t.co/VeBaOqvuJs |
https://twitter.com/nikkei/statuses/1643414636413468674
|
議長 |
2023-04-05 00:45:57 |
ニュース |
@日本経済新聞 電子版 |
南海トラフ地震の死者8割減「達成困難」 新目標策定へ
https://t.co/wyLeUvneM0 |
https://twitter.com/nikkei/statuses/1643413004510453763
|
南海トラフ地震 |
2023-04-05 00:39:28 |
ニュース |
@日本経済新聞 電子版 |
【NIKKEI FT the World】
アフリカのリチウム争奪戦、中国が欧米を圧倒
https://t.co/t6aYqz6JQ2 |
https://twitter.com/nikkei/statuses/1643410697290756097
|
nikkeifttheworld |
2023-04-05 00:30:17 |
ニュース |
@日本経済新聞 電子版 |
日経平均、反落で始まる 下げ幅一時200円超
https://t.co/QPyYehlclD |
https://twitter.com/nikkei/statuses/1643407834888179712
|
日経平均 |
2023-04-05 00:18:55 |
ニュース |
@日本経済新聞 電子版 |
英当局、TikTokに21億円の罰金 個人データで違反
https://t.co/xJ10hiU8Po |
https://twitter.com/nikkei/statuses/1643405843990462464
|
tiktok |
2023-04-05 00:11:00 |
ニュース |
BBC News - Home |
Donald Trump has been charged. What happens next? |
https://www.bbc.co.uk/news/world-us-canada-65184050?at_medium=RSS&at_campaign=KARANGA
|
thrown |
2023-04-05 00:08:13 |
ニュース |
BBC News - Home |
Businesses in NI face perfect storm warning |
https://www.bbc.co.uk/news/uk-northern-ireland-65167982?at_medium=RSS&at_campaign=KARANGA
|
business |
2023-04-05 00:12:00 |
マーケティング |
MarkeZine |
データに価値をもたらし、事業を発展させる「保険事業」という機能 |
http://markezine.jp/article/detail/41734
|
bicpmadmanreport |
2023-04-05 09:30:00 |
デザイン |
Webクリエイターボックス |
2023年3月に読んだWeb・デザイン関連の本 |
https://www.webcreatorbox.com/books/2023-3
|
firstappearedonweb |
2023-04-05 00:00:44 |
コメント
コメントを投稿